From patchwork Fri Feb 16 18:37:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 85899 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C40993857707 for ; Fri, 16 Feb 2024 18:39:10 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) by sourceware.org (Postfix) with ESMTPS id B98403857C49 for ; Fri, 16 Feb 2024 18:37:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B98403857C49 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B98403857C49 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d30 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708108674; cv=none; b=mmnQPLwWMf1O7flBOceu2TbIPIFHkdl7Pv3K7xaHNupwubOfD/9uih1FPgMyNZh+7Lps1crs/ub+TjZXaNhNdpyJrgxmwe60HZfjyQKd/SJQaZKKZAMUdji60fvZsPm/KNVQbIYud6H/nBKSz9BCMnbET9u+SNtDYNxbi5EdPeo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708108674; c=relaxed/simple; bh=t09SdwRudMbVBcndZindSU6SS1IXjjRdXw9ES4u7iUE=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=tSE7hSTxQWX6SuNMXS4K8eh5ZqrwD4d+VfI3hRozLJn7QBJeDN8wM82vBwBoFHRpQbHLY4b3wU+noh1NEGuy8wrOqNSMXrouk4XjbJceHlImX3wgoXRwgb1L22BnJ8lSi7Rz+nRibJ8ErfudTSu7hB7SWTwiswtWYG7cV3osi9Y= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd30.google.com with SMTP id ca18e2360f4ac-7c490498729so105513739f.1 for ; Fri, 16 Feb 2024 10:37:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1708108672; x=1708713472; darn=sourceware.org; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=4x5aHKAslof5IK0Al5CTnhGXkIKjgTXhoVLuKlZ+O88=; b=fAClUGGuweh371Nz/tZBe3Q1hJAEuN/oQqjmt50qStocZLMHmc48qjarGriZfmk7wc 4stVHRXXT8+0ZVtglOsZ1z/dMV8jUTIWt26/T6wz2VYijSy5AJy9PCTkxmqrxd9ec1Q2 1+Shclqsc18vw4/RB39xQhdiixuGU69K5QFrQnfOBqYdA95T41gxVOpH/lB8OR7Y29YP IP/k8IINr7TThLfPnkdV/hbCaL7DwBRoTl0qvVQT7XcomCGW4+x+7KjIgtTvgHwkUCB0 G6gckNvtXmrLEr1ZzjP4HuxOlkFAGVOR7ev7GXSpEOoEvFI4ihAeai6/QvgU3aMziUw4 CF0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708108672; x=1708713472; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4x5aHKAslof5IK0Al5CTnhGXkIKjgTXhoVLuKlZ+O88=; b=BXpc7lGQeOmhQlKkoxcyNQtkbNkSBnbaUeWy/oSY9xLB58gvyiQxU21twW9Z8QLMm1 YSPMJY6X83B9P3hG3hSI4RDzRv6BEJCpk0mP11Jdb9DHQPRxPcwmc8SkTDe5fuC6oDtm OuF2aW3E++sasU47cmBxxdmeew0jW0jqnJZ5ieywgVAUfgUve2q1taLUYQ7bXZELshBN SZOFZJtNK470iBPy2UnsCK8rxkOdKF1oHN4fMfAJuwTZkv7EnFMmbchUl2RAGTQASUdN WOKyTFj3Rw1MDtiyM/2bCQs4RUzVx2UIP8A3E/WRQjl5yv7L4XMSCTaIxcK/PegOdWm8 mGBQ== X-Gm-Message-State: AOJu0Yw4I1SeqnwZAWSzcL0+Xe1ICXNHzI6zjP8V6G17GLJRKWddMWbb HcuLECsPJX6MpcXNg2HPuwjMgOAOto8ZK5AYLX3h8v0rWpyVkF8ArygC47rJkPYjyT5wI4UTEaE = X-Google-Smtp-Source: AGHT+IG7AiOL0BYRFKw5WsKhPFuGspqmjtpXF1vn5MumV2CAQUfgH6BLlWm28mufYfkN+zylTuiexQ== X-Received: by 2002:a6b:6b08:0:b0:7c4:9047:b9b8 with SMTP id g8-20020a6b6b08000000b007c49047b9b8mr5641286ioc.3.1708108671455; Fri, 16 Feb 2024 10:37:51 -0800 (PST) Received: from localhost.localdomain (71-211-170-195.hlrn.qwest.net. [71.211.170.195]) by smtp.gmail.com with ESMTPSA id g20-20020a0566380bd400b00473eb9f9afcsm104724jad.61.2024.02.16.10.37.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 10:37:51 -0800 (PST) From: Tom Tromey Date: Fri, 16 Feb 2024 11:37:49 -0700 Subject: [PATCH 1/5] Introduce new overload of read_text_file_to_string MIME-Version: 1.0 Message-Id: <20240216-py-simple-exc-v1-1-c275bcfb5e4a@adacore.com> References: <20240216-py-simple-exc-v1-0-c275bcfb5e4a@adacore.com> In-Reply-To: <20240216-py-simple-exc-v1-0-c275bcfb5e4a@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org This patch adds a new overload of read_text_file_to_string. This one reads from an existing 'FILE *'. This will be used in a subsequent patch. --- gdbsupport/filestuff.cc | 24 ++++++++++++++++-------- gdbsupport/filestuff.h | 4 ++++ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/gdbsupport/filestuff.cc b/gdbsupport/filestuff.cc index c67e650c1a6..70bcc3faf60 100644 --- a/gdbsupport/filestuff.cc +++ b/gdbsupport/filestuff.cc @@ -504,13 +504,9 @@ mkdir_recursive (const char *dir) /* See gdbsupport/filestuff.h. */ -std::optional -read_text_file_to_string (const char *path) +std::string +read_text_file_to_string (FILE *file) { - gdb_file_up file = gdb_fopen_cloexec (path, "r"); - if (file == nullptr) - return {}; - std::string res; for (;;) { @@ -520,7 +516,7 @@ read_text_file_to_string (const char *path) /* Resize to accommodate CHUNK_SIZE bytes. */ res.resize (start_size + chunk_size); - int n = fread (&res[start_size], 1, chunk_size, file.get ()); + int n = fread (&res[start_size], 1, chunk_size, file); if (n == chunk_size) continue; @@ -528,7 +524,7 @@ read_text_file_to_string (const char *path) /* Less than CHUNK means EOF or error. If it's an error, return no value. */ - if (ferror (file.get ())) + if (ferror (file)) return {}; /* Resize the string according to the data we read. */ @@ -538,3 +534,15 @@ read_text_file_to_string (const char *path) return res; } + +/* See gdbsupport/filestuff.h. */ + +std::optional +read_text_file_to_string (const char *path) +{ + gdb_file_up file = gdb_fopen_cloexec (path, "r"); + if (file == nullptr) + return {}; + + return read_text_file_to_string (file.get ()); +} diff --git a/gdbsupport/filestuff.h b/gdbsupport/filestuff.h index 1c43b7de0ca..4a90b08c5f3 100644 --- a/gdbsupport/filestuff.h +++ b/gdbsupport/filestuff.h @@ -133,4 +133,8 @@ extern bool mkdir_recursive (const char *dir); extern std::optional read_text_file_to_string (const char *path); +/* Read the entire content of FILE into an std::string. */ + +extern std::string read_text_file_to_string (FILE *file); + #endif /* COMMON_FILESTUFF_H */ From patchwork Fri Feb 16 18:37:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 85896 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4E703385782D for ; Fri, 16 Feb 2024 18:38:28 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by sourceware.org (Postfix) with ESMTPS id E78753857C77 for ; Fri, 16 Feb 2024 18:37:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E78753857C77 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E78753857C77 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::12d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708108674; cv=none; b=jADXvt/yXsINScJ9LET7WW807Uy6uATCnIcp9pifVpML3ZpOdYE0WiJYIq7chDpEn10EuHkaNRqCvV8OrCPKEn7NhFMzw8gjJIDkqsub43u8MrQ0aMOsXsHXfstEPD689zZaj2fq+J/irhhRlrRVFP4qR40T7D1EtiXKeXp9ECU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708108674; c=relaxed/simple; bh=vAj9gCZA+iCXEtBuP1ZSPwUgD9WMdWd+ZeDX7llMVnQ=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=CSoDt47COse4l7JhJ8LBj/YGc0rTY/xEWhci5ex6Tuf5vSd/grDdFrdrNvig44H1zLiF6UUTpnKPnkcG38yusAzgFCCX+nN6AfCMo52EGxRwb2+S0aevZkjB3pIDCmfAVZRbu5YF7YqXLxIb5AvwcbtHfACRzsaz3xv6WVT3RT8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-il1-x12d.google.com with SMTP id e9e14a558f8ab-363bdac74c6so6304795ab.2 for ; Fri, 16 Feb 2024 10:37:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1708108672; x=1708713472; darn=sourceware.org; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=bxbfoU/T2Tv7yGfFkcbD27rhFiZu1Ahi4n5+EJsMOhQ=; b=f2bJNhl0Rr32AlB2bG5VYAzWitZeXAGjV5XbdtQQ6LQ8oVXaQGS4zIY2/YuJNmRRDF 48yC/7aDty0olV0Q1SuP+FrCYrsGh8rz14HX5/uezN8pRnRGsm2v+8eK5SSZtRGTR8uM wJDHLKWiDr2GT0sJM7Bm+NulYcMdoioh8GTI2PdyJVKyfYwAqpd//GWkZRCyM3EowBhw FDi+AyC1+aAoP3rbrIhkC4D+cpsq0fOFEkPbZLVFdpAgEGS03FGHnv47Do2DpOoz08wU k47NRGHbbNPJ7bz1l5QSVYMtYaRMkSZC0IT1y8avkX6NLTOL8LsnSMlx7SjEibJNRZdU Jy4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708108672; x=1708713472; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bxbfoU/T2Tv7yGfFkcbD27rhFiZu1Ahi4n5+EJsMOhQ=; b=ryAAs80iC2DY4zOL2jvfE0SalRHB3x4Jp3uBS3lzCx9UPMcfLhzsQFmOex2n+Alamf gufc3908iMkqBkXdvxPghwjMBaMhkjcrAk8Dxh9iXvElktxrJXmdf7tQ0Dvxi3KbDzqL wNQWtuJhbBCoa2AwrRmnaIPXinm377DtSzYSLAclptaP/XNgxegmDa3HgzIP/9lCp8Ry p6yeaYa9/0l+5tGVI3ELHN5/R3t6A4c7FOnHPe5vgAx7GkzrcGqrXZprYP56Bal3gVLj vs/xkwf4Wqrhruc+zDyk/I5EtCggtjliG+F5HW9xxR+QM8n5CHz1G/FgKhLVbZRFdyx5 GbsA== X-Gm-Message-State: AOJu0YxdaaCKrmSgfD84ROz85me6KZBunBPEnKS5hF4XXaWBygUD4uYn dQxjnzoDtcSS0qjQ1tHFtPnnRSr7ZPxbRVFNDpINFjgPUOC5kcerpDi4MxVmdQ7NKtQwUiLShSg = X-Google-Smtp-Source: AGHT+IHsPVvRdCRIUncescgxtTdRQ30YlqndaAIXmq7vSvmhQ3HdLWDtcQcn69Yr5DOdUhxSEIUxag== X-Received: by 2002:a05:6e02:1301:b0:365:16c8:ca7c with SMTP id g1-20020a056e02130100b0036516c8ca7cmr699898ilr.23.1708108672092; Fri, 16 Feb 2024 10:37:52 -0800 (PST) Received: from localhost.localdomain (71-211-170-195.hlrn.qwest.net. [71.211.170.195]) by smtp.gmail.com with ESMTPSA id g20-20020a0566380bd400b00473eb9f9afcsm104724jad.61.2024.02.16.10.37.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 10:37:51 -0800 (PST) From: Tom Tromey Date: Fri, 16 Feb 2024 11:37:50 -0700 Subject: [PATCH 2/5] Fix formatting buglet in python.c MIME-Version: 1.0 Message-Id: <20240216-py-simple-exc-v1-2-c275bcfb5e4a@adacore.com> References: <20240216-py-simple-exc-v1-0-c275bcfb5e4a@adacore.com> In-Reply-To: <20240216-py-simple-exc-v1-0-c275bcfb5e4a@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org python.c has a split string that is missing a space. There's also a stray backslash in this code. --- gdb/python/python.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/python/python.c b/gdb/python/python.c index 845abb3aa86..09b1029e0b7 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -1572,7 +1572,7 @@ gdbpy_print_stack (void) /* An error occurred computing the string representation of the error message. */ gdb_printf (gdb_stderr, - _("Error occurred computing Python error" \ + _("Error occurred computing Python error " "message.\n")); PyErr_Clear (); } From patchwork Fri Feb 16 18:37:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 85900 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 616473857833 for ; Fri, 16 Feb 2024 18:39:11 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-il1-x134.google.com (mail-il1-x134.google.com [IPv6:2607:f8b0:4864:20::134]) by sourceware.org (Postfix) with ESMTPS id 7B37D3857B86 for ; Fri, 16 Feb 2024 18:37:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7B37D3857B86 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7B37D3857B86 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::134 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708108675; cv=none; b=e7BzFpd1ULFlR32VG9QY8G5IcvIP7yl8YXYExkFsydpndDiGfdrik7X22rhHvh13dL2LdJ8lM/XGXPGkBkbboCDM8Xmbq/3NspjYtdo9awRcgcFbDMsyHOILXWyW9zRXo+poLSDQgIRZolVZpdl0bZsvqu4Ia5tI+cZcmuRnm48= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708108675; c=relaxed/simple; bh=IVLDgjYF6AO7UyLVgTsCCLMgseMbqKPR4J2zuG+N9ws=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=ho7wPkxL661JW7JTqavot1o8EW3eXtX5YCR3t1+u6JD/YDK/nqVmrE39gFM+loi4dzjkwvDLYjfNg9yivbqhLpd69cOgp6offrZfJr/MKG9/Y41YSu/wZ7OK6q/vjjz9vB3c6prpOpr9Ku4Y23VtTWPq8Mkq8rdcV8lxQvFVvFY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-il1-x134.google.com with SMTP id e9e14a558f8ab-364f8246c8cso5686765ab.2 for ; Fri, 16 Feb 2024 10:37:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1708108672; x=1708713472; darn=sourceware.org; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=W08w9mDsW/if1berqk2+vmt/mY1riIPKEc3f7BmYuMQ=; b=StMwmPPFRgwn9hpDdiPG3JyiK5xXcJ2Qnzd71Ggf7A06GH04UNv1Vz8RQ8EKI/Gsjx +Hd5B4LHqf9AV29HS4DjcGNM4rcI5OlfcljuB1xCzBMqUW9j3BLvAEHw3496zLbqBkzt MwkrdgOAS/DxoiDUDz4GkgCKZ9CrVA/HFP+xsMXqmB19T7eNZF4HqbcYTjkiEnYj1A3Q V2XpjIixnf6dd8fQoEqpERGXuhxYMLxAu94hQBweM7pqyXB1U3UUgF6y8FFzHczKziCF v4MX/TRJqRWh7y/jeSN4TVpD4C5P6dsJiWbRi3UT/y3f7ogeHhjrtDw+l/cnl2iHGpNY z5nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708108672; x=1708713472; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W08w9mDsW/if1berqk2+vmt/mY1riIPKEc3f7BmYuMQ=; b=w1Pr8DTkaP9EqhN1iDJTbUWz0IdLX/EWeJUcZbD/uYnohjdoQLwOi6SNbJMTrhQimZ kYUsooa5ljm//MCIcUIUJvfOQIvGFMH1bcecd9Nkbip4pLZxwuj2xQBUD1q8Q/3aJQRW ZoacxTruYQnBILCfUwc8N3ysUbsBgaPXBrQBYwsnKr6PahqPR/II+5d/FHvplrdtl7oT oZkQlMyRmp56IUF006V2Q2qqWP63hLVeylTI5R/zLP28pmAlTuoo/EeNzww175EDbxvM nhtNoTUC/PXdDGgcD16b2xEwA/5NRcvCUztdbysnj2f/ZXN1ob09Mhv1bl6H1VwfNvyQ BOBQ== X-Gm-Message-State: AOJu0Yzlmlt2tSNU3pt1YbWduX2Yal0Z46nvKZUOzBhKyYYdjuq29c5g otYADynaOHjb00d7dUGa+Mf811wRkwTDLUgPNgOnC40MrvZYZ4hAqth+v93UuN9nvPYDP2BL9oY = X-Google-Smtp-Source: AGHT+IHkk9IlNwQAnl2oC0tU9DV1Gls+7n8BbXWMef4gYWSnIWTSTiv1ksgrNtaOkdutab3+aXlwNg== X-Received: by 2002:a05:6e02:198b:b0:364:2238:732a with SMTP id g11-20020a056e02198b00b003642238732amr7841258ilf.25.1708108672650; Fri, 16 Feb 2024 10:37:52 -0800 (PST) Received: from localhost.localdomain (71-211-170-195.hlrn.qwest.net. [71.211.170.195]) by smtp.gmail.com with ESMTPSA id g20-20020a0566380bd400b00473eb9f9afcsm104724jad.61.2024.02.16.10.37.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 10:37:52 -0800 (PST) From: Tom Tromey Date: Fri, 16 Feb 2024 11:37:51 -0700 Subject: [PATCH 3/5] kfail a FinishBreakpoint test MIME-Version: 1.0 Message-Id: <20240216-py-simple-exc-v1-3-c275bcfb5e4a@adacore.com> References: <20240216-py-simple-exc-v1-0-c275bcfb5e4a@adacore.com> In-Reply-To: <20240216-py-simple-exc-v1-0-c275bcfb5e4a@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org I noticed that one particular FinishBreakpoint test is only passing by accident -- the regexp is too broad and matches an error message. This patch changes the test to actually check what it claims to check; and then kfails the test because it doesn't work. I've taken this approach because this failure is only incidental to this series. Meanwhile I've filed a bug that I will leave open after this lands. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31391 --- gdb/testsuite/gdb.python/py-finish-breakpoint.exp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.python/py-finish-breakpoint.exp b/gdb/testsuite/gdb.python/py-finish-breakpoint.exp index 45e2630337f..6b72ddb2186 100644 --- a/gdb/testsuite/gdb.python/py-finish-breakpoint.exp +++ b/gdb/testsuite/gdb.python/py-finish-breakpoint.exp @@ -73,7 +73,11 @@ with_test_prefix "normal conditions" { "check MyFinishBreakpoint hit" gdb_test "python print (finishbp.return_value)" "-5.*" "check return_value" - gdb_test "python print (finishbp_default.hit_count)" "1.*" "check finishBP on default frame has been hit" + # This test does not work and the result being checked for here + # used to match by accident. See PR python/31391. + setup_kfail "python/31391" *-*-* + gdb_test "python print ('HC=' + str(finishbp_default.hit_count))" "HC=1" \ + "check finishBP on default frame has been hit" gdb_test "python print (finishbp.is_valid())" "False.*"\ "ensure that finish bp is invalid afer normal hit" From patchwork Fri Feb 16 18:37:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 85898 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0837F3857BB1 for ; Fri, 16 Feb 2024 18:39:04 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by sourceware.org (Postfix) with ESMTPS id 241723857B95 for ; Fri, 16 Feb 2024 18:37:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 241723857B95 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 241723857B95 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d2b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708108682; cv=none; b=SHboXR/EFJIfAdq3qnuPN9kdTc5xOAAzvECNVRwMDMyNHcx0h3qXVSck47v0lSFtTXzpLmAddDOBdycbnSc02wXnRrTpUGLdqt/MuIbcaeIinW3hIhK4KWqo2H7Q57K55690vBpRY/kJ/+3tmqYOxWhQ/bZP1vU1by/087tSxA0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708108682; c=relaxed/simple; bh=ptIoKxbtyODo9C6/nrB28BMt8FKqLhLrESGEWXrNc/c=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=SWZEusmSQiSS3/CFihymcdrvDEDo/KN1pOSJ92te9bNH8h/F446S7UH2AluAx3X8R7PQ0Ip/khIp/9EB6Mtpdj2yhpwbXJdn1RdXTL12r3A1dgmpbUQ1M9YS6ZnFQYI9Z7jJ+ZnApIVirlBF4BoY52vXnOvpmMtwmhDcyVwW2sk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd2b.google.com with SMTP id ca18e2360f4ac-7c7242db3fbso25679139f.0 for ; Fri, 16 Feb 2024 10:37:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1708108674; x=1708713474; darn=sourceware.org; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=gwitVUDprVX/YOG9Fep6iqD2VGYie80lzw+8OU3NjpM=; b=PveVrjxVRugtiJbwX8FOavSsnu1h0TnOQAZvnKxS3fhset8Y/06KpyCHWDGXTDnbj4 nFjO6D1HCg7mOT+RvkWVCtOY5Nq2+tT8QjhtfBwmpHrJ5ATXm4jSjnTURqSne5P6I3qz Mf7KiZ3jD9azrqBIY5uF2hhWDroRgYOl0VngEF9LEQRzH3l7NVuuPkwcjCCUkYuGrp+p AsxXl6vELoBz9l1K37pNYVGLGVP/06iKaA+u8NfRvRhPAkR/kAqgvyF6ve5BQiPURIHW 1qM+aOT/S/dZBxLksq6NWiXIer0S2XQiJASCCXfoYbcNUO+hEEStirvsu1BDPH0/g4vd NoiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708108674; x=1708713474; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gwitVUDprVX/YOG9Fep6iqD2VGYie80lzw+8OU3NjpM=; b=MfwOayzVYK+OGxz3nq6pbdwLPG4tSz+C8Ael9nsQ9RPPhS29xhgPeWV4KcFdE4eBOD 6P/H6qX8axVxg1SSS4PUS8Mx0pOPCJT+TwsiMzUut1g7j0r9dBet9mP+Sv0i/Gu+m3Iv fT7NRVzGUlBgRBSPLkp/+o52cFP3nFKyFfcYykOH+yOyb9xVH+FEDEfKaChxtzwBwaKS 57MCCXu8ogna2j4CEdd3oC6oX9h1A+D36RdM8gOtQrPxKnUaAM/PsJLvabZwZ030Zwi7 r6ammizHu9oTBCNgHcXao6aks0PAIWCaW9RozAWoCE9gLwT3226yIh1qRvzdwKuynHjp f+tQ== X-Gm-Message-State: AOJu0Ywljlxh/VRuosT8f9P1Ehd5i8VCDz6sPxXw7gXr3AZxPZ9r1oi/ 8iefszSf6a/6ZgFOZuu3Lq2RzQpllqToS6cOHBSRh5JABFNZiAASenLATDCDk0+VK2IGIYmf2r8 = X-Google-Smtp-Source: AGHT+IF9oTGSnWbnQW2ccqZLGOGHScGPktdOvi6JD3a9xQXgMpspnXm/mYuJypPCbpl1rGL6Fkv0Xw== X-Received: by 2002:a5d:9584:0:b0:7c4:9459:3762 with SMTP id a4-20020a5d9584000000b007c494593762mr6292542ioo.9.1708108673469; Fri, 16 Feb 2024 10:37:53 -0800 (PST) Received: from localhost.localdomain (71-211-170-195.hlrn.qwest.net. [71.211.170.195]) by smtp.gmail.com with ESMTPSA id g20-20020a0566380bd400b00473eb9f9afcsm104724jad.61.2024.02.16.10.37.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 10:37:52 -0800 (PST) From: Tom Tromey Date: Fri, 16 Feb 2024 11:37:52 -0700 Subject: [PATCH 4/5] Rewrite "python" command exception handling MIME-Version: 1.0 Message-Id: <20240216-py-simple-exc-v1-4-c275bcfb5e4a@adacore.com> References: <20240216-py-simple-exc-v1-0-c275bcfb5e4a@adacore.com> In-Reply-To: <20240216-py-simple-exc-v1-0-c275bcfb5e4a@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org The "python" command (and the Python implementation of the gdb "source" command) does not handle Python exceptions in the same way as other gdb-facing Python code. In particular, exceptions are turned into a generic error rather than being routed through gdbpy_handle_exception, which takes care of converting to 'quit' as appropriate. I think this was done this way because PyRun_SimpleFile and friends do not propagate the Python exception -- they simply indicate that one occurred. This patch reimplements these functions to respect the general gdb convention here. As a bonus, some Windows-specific code can be removed, as can the _execute_file function. The bulk of this change is tweaking the test suite to match the new way that exceptions are displayed. These changes are largely uninteresting. However, it's worth pointing out the py-error.exp change. Here, the failure changes because the test changes the host charset to something that isn't supported by Python. This then results in a weird error in the new setup. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31354 --- gdb/python/lib/gdb/__init__.py | 27 ------ gdb/python/python.c | 109 +++++++++------------- gdb/testsuite/gdb.ada/tasks.exp | 8 +- gdb/testsuite/gdb.python/py-arch.exp | 2 +- gdb/testsuite/gdb.python/py-block.exp | 4 +- gdb/testsuite/gdb.python/py-breakpoint.exp | 18 ++-- gdb/testsuite/gdb.python/py-connection.exp | 8 +- gdb/testsuite/gdb.python/py-disasm.exp | 32 +++---- gdb/testsuite/gdb.python/py-error.exp | 9 +- gdb/testsuite/gdb.python/py-finish-breakpoint.exp | 2 +- gdb/testsuite/gdb.python/py-format-address.exp | 28 +++--- gdb/testsuite/gdb.python/py-format-string.exp | 8 +- gdb/testsuite/gdb.python/py-frame.exp | 18 ++-- gdb/testsuite/gdb.python/py-inferior.exp | 24 ++--- gdb/testsuite/gdb.python/py-lazy-string.exp | 6 +- gdb/testsuite/gdb.python/py-mi-cmd.exp | 40 ++++---- gdb/testsuite/gdb.python/py-missing-debug.exp | 16 ++-- gdb/testsuite/gdb.python/py-objfile.exp | 2 +- gdb/testsuite/gdb.python/py-parameter.exp | 14 +-- gdb/testsuite/gdb.python/py-pp-registration.exp | 2 +- gdb/testsuite/gdb.python/py-progspace-events.exp | 2 +- gdb/testsuite/gdb.python/py-progspace.exp | 8 +- gdb/testsuite/gdb.python/py-record-btrace.exp | 4 +- gdb/testsuite/gdb.python/py-record-full.exp | 4 +- gdb/testsuite/gdb.python/py-template.exp | 2 +- gdb/testsuite/gdb.python/py-thrhandle.exp | 2 +- gdb/testsuite/gdb.python/py-type.exp | 20 ++-- gdb/testsuite/gdb.python/py-unwind.exp | 24 ++--- gdb/testsuite/gdb.python/py-value.exp | 36 +++---- gdb/testsuite/gdb.python/python.exp | 10 +- gdb/testsuite/gdb.python/tui-window-names.exp | 16 ++-- gdb/testsuite/gdb.python/tui-window.exp | 2 +- 32 files changed, 233 insertions(+), 274 deletions(-) diff --git a/gdb/python/lib/gdb/__init__.py b/gdb/python/lib/gdb/__init__.py index ce8a6aae01e..cb3732e55f5 100644 --- a/gdb/python/lib/gdb/__init__.py +++ b/gdb/python/lib/gdb/__init__.py @@ -127,33 +127,6 @@ def _execute_unwinders(pending_frame): return None -def _execute_file(filepath): - """This function is used to replace Python 2's PyRun_SimpleFile. - - Loads and executes the given file. - - We could use the runpy module, but its documentation says: - "Furthermore, any functions and classes defined by the executed code are - not guaranteed to work correctly after a runpy function has returned." - """ - globals = sys.modules["__main__"].__dict__ - set_file = False - # Set file (if not set) so that the imported file can use it (e.g. to - # access file-relative paths). This matches what PyRun_SimpleFile does. - if not hasattr(globals, "__file__"): - globals["__file__"] = filepath - set_file = True - try: - with open(filepath, "rb") as file: - # We pass globals also as locals to match what Python does - # in PyRun_SimpleFile. - compiled = compile(file.read(), filepath, "exec") - exec(compiled, globals, globals) - finally: - if set_file: - del globals["__file__"] - - # Convenience variable to GDB's python directory PYTHONDIR = os.path.dirname(os.path.dirname(__file__)) diff --git a/gdb/python/python.c b/gdb/python/python.c index 09b1029e0b7..c41a7b6cbc4 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -284,12 +284,14 @@ gdbpy_check_quit_flag (const struct extension_language_defn *extlang) return PyOS_InterruptOccurred (); } -/* Evaluate a Python command like PyRun_SimpleString, but uses - Py_single_input which prints the result of expressions, and does - not automatically print the stack on errors. */ +/* Evaluate a Python command like PyRun_SimpleString, but takes a + Python start symbol, and does not automatically print the stack on + errors. FILENAME is used to set the file name in error + messages. */ static int -eval_python_command (const char *command) +eval_python_command (const char *command, int start_symbol, + const char *filename = "") { PyObject *m, *d; @@ -300,8 +302,15 @@ eval_python_command (const char *command) d = PyModule_GetDict (m); if (d == NULL) return -1; - gdbpy_ref<> v (PyRun_StringFlags (command, Py_single_input, d, d, NULL)); - if (v == NULL) + + /* Use this API because it is in Python 3.2. */ + gdbpy_ref<> code (Py_CompileStringExFlags (command, filename, start_symbol, + nullptr, -1)); + if (code == nullptr) + return -1; + + gdbpy_ref<> result (PyEval_EvalCode (code.get (), d, d)); + if (result == nullptr) return -1; return 0; @@ -324,7 +333,8 @@ python_interactive_command (const char *arg, int from_tty) if (arg && *arg) { std::string script = std::string (arg) + "\n"; - err = eval_python_command (script.c_str ()); + /* Py_single_input causes the result to be displayed. */ + err = eval_python_command (script.c_str (), Py_single_input); } else { @@ -333,14 +343,12 @@ python_interactive_command (const char *arg, int from_tty) } if (err) - { - gdbpy_print_stack (); - error (_("Error while executing Python code.")); - } + gdbpy_handle_exception (); } -/* A wrapper around PyRun_SimpleFile. FILE is the Python script to run - named FILENAME. +/* Like PyRun_SimpleFile, but if there is an exception, it is not + automatically displayed. FILE is the Python script to run named + FILENAME. On Windows hosts few users would build Python themselves (this is no trivial task on this platform), and thus use binaries built by @@ -349,39 +357,13 @@ python_interactive_command (const char *arg, int from_tty) library. Python, being built with VC, would use one version of the msvcr DLL (Eg. msvcr100.dll), while MinGW uses msvcrt.dll. A FILE * from one runtime does not necessarily operate correctly in - the other runtime. + the other runtime. */ - To work around this potential issue, we run code in Python to load - the script. */ - -static void +static int python_run_simple_file (FILE *file, const char *filename) { -#ifndef _WIN32 - - PyRun_SimpleFile (file, filename); - -#else /* _WIN32 */ - - /* Because we have a string for a filename, and are using Python to - open the file, we need to expand any tilde in the path first. */ - gdb::unique_xmalloc_ptr full_path (tilde_expand (filename)); - - if (gdb_python_module == nullptr - || ! PyObject_HasAttrString (gdb_python_module, "_execute_file")) - error (_("Installation error: gdb._execute_file function is missing")); - - gdbpy_ref<> return_value - (PyObject_CallMethod (gdb_python_module, "_execute_file", "s", - full_path.get ())); - if (return_value == nullptr) - { - /* Use PyErr_PrintEx instead of gdbpy_print_stack to better match the - behavior of the non-Windows codepath. */ - PyErr_PrintEx(0); - } - -#endif /* _WIN32 */ + std::string contents = read_text_file_to_string (file); + return eval_python_command (contents.c_str (), Py_file_input, filename); } /* Given a command_line, return a command string suitable for passing @@ -408,17 +390,15 @@ static void gdbpy_eval_from_control_command (const struct extension_language_defn *extlang, struct command_line *cmd) { - int ret; - if (cmd->body_list_1 != nullptr) error (_("Invalid \"python\" block structure.")); gdbpy_enter enter_py; std::string script = compute_python_string (cmd->body_list_0.get ()); - ret = PyRun_SimpleString (script.c_str ()); - if (ret) - error (_("Error while executing Python code.")); + int ret = eval_python_command (script.c_str (), Py_file_input); + if (ret != 0) + gdbpy_handle_exception (); } /* Implementation of the gdb "python" command. */ @@ -433,8 +413,9 @@ python_command (const char *arg, int from_tty) arg = skip_spaces (arg); if (arg && *arg) { - if (PyRun_SimpleString (arg)) - error (_("Error while executing Python code.")); + int ret = eval_python_command (arg, Py_file_input); + if (ret != 0) + gdbpy_handle_exception (); } else { @@ -1021,7 +1002,9 @@ gdbpy_source_script (const struct extension_language_defn *extlang, FILE *file, const char *filename) { gdbpy_enter enter_py; - python_run_simple_file (file, filename); + int result = python_run_simple_file (file, filename); + if (result != 0) + gdbpy_handle_exception (); } @@ -1653,7 +1636,9 @@ gdbpy_source_objfile_script (const struct extension_language_defn *extlang, scoped_restore restire_current_objfile = make_scoped_restore (&gdbpy_current_objfile, objfile); - python_run_simple_file (file, filename); + int result = python_run_simple_file (file, filename); + if (result != 0) + gdbpy_print_stack (); } /* Set the current objfile to OBJFILE and then execute SCRIPT @@ -1674,7 +1659,9 @@ gdbpy_execute_objfile_script (const struct extension_language_defn *extlang, scoped_restore restire_current_objfile = make_scoped_restore (&gdbpy_current_objfile, objfile); - PyRun_SimpleString (script); + int ret = eval_python_command (script, Py_file_input); + if (ret != 0) + gdbpy_print_stack (); } /* Return the current Objfile, or None if there isn't one. */ @@ -2332,21 +2319,15 @@ test_python () { CMD (output); } - catch (const gdb_exception &e) + catch (const gdb_exception_quit &e) { saw_exception = true; - SELF_CHECK (e.reason == RETURN_ERROR); - SELF_CHECK (e.error == GENERIC_ERROR); - SELF_CHECK (*e.message == "Error while executing Python code."); + SELF_CHECK (e.reason == RETURN_QUIT); + SELF_CHECK (e.error == GDB_NO_ERROR); + SELF_CHECK (*e.message == "Quit"); } SELF_CHECK (saw_exception); - std::string ref_output_0 ("Traceback (most recent call last):\n" - " File \"\", line 0, in \n" - "KeyboardInterrupt\n"); - std::string ref_output_1 ("Traceback (most recent call last):\n" - " File \"\", line 1, in \n" - "KeyboardInterrupt\n"); - SELF_CHECK (output == ref_output_0 || output == ref_output_1); + SELF_CHECK (output.empty ()); } #undef CMD diff --git a/gdb/testsuite/gdb.ada/tasks.exp b/gdb/testsuite/gdb.ada/tasks.exp index dd03a2e4a96..6e588408c9d 100644 --- a/gdb/testsuite/gdb.ada/tasks.exp +++ b/gdb/testsuite/gdb.ada/tasks.exp @@ -98,15 +98,15 @@ if {[allow_python_tests]} { gdb_test "python print(bp.thread)" "None" gdb_test "python bp.thread = 1" \ [multi_line \ - "RuntimeError: Cannot set both task and thread attributes\\." \ - "Error while executing Python code\\."] \ + "RuntimeError.*: Cannot set both task and thread attributes\\." \ + "Error occurred in Python.*"] \ "try setting the thread, but expect an error" gdb_test_no_output "python bp.task = None" gdb_test_no_output "python bp.thread = 1" gdb_test "python bp.task = 3" \ [multi_line \ - "RuntimeError: Cannot set both task and thread attributes\\." \ - "Error while executing Python code\\."] \ + "RuntimeError.*: Cannot set both task and thread attributes\\." \ + "Error occurred in Python.*"] \ "try setting the task, but expect an error" # Reset the breakpoint to the state required for the rest of this diff --git a/gdb/testsuite/gdb.python/py-arch.exp b/gdb/testsuite/gdb.python/py-arch.exp index 1b0759a657d..3c58bf1281f 100644 --- a/gdb/testsuite/gdb.python/py-arch.exp +++ b/gdb/testsuite/gdb.python/py-arch.exp @@ -91,7 +91,7 @@ foreach size {0 1 2 3 4 8 16} { } gdb_test "python arch.integer_type(95)" \ - ".*ValueError: no integer type of that size is available.*" \ + ".*ValueError.* no integer type of that size is available.*" \ "call integer_type with invalid size" # Test for gdb.architecture_names(). First we're going to grab the diff --git a/gdb/testsuite/gdb.python/py-block.exp b/gdb/testsuite/gdb.python/py-block.exp index 5e8fba43ea0..942611af305 100644 --- a/gdb/testsuite/gdb.python/py-block.exp +++ b/gdb/testsuite/gdb.python/py-block.exp @@ -44,9 +44,9 @@ gdb_test "python print (block.function)" "None" "first anonymous block" gdb_test "python print (block.start)" "${decimal}" "check start not None" gdb_test "python print (block.end)" "${decimal}" "check end not None" gdb_test "python print (block\['f'\].name == 'f')" "True" "check variable access" -gdb_test "python print (block\['nonexistent'\])" ".*KeyError: 'nonexistent'.*" \ +gdb_test "python print (block\['nonexistent'\])" ".*KeyError.*: nonexistent.*" \ "check nonexistent variable" -gdb_test "python print (block\[42\])" ".*TypeError: Expected a string.*" \ +gdb_test "python print (block\[42\])" ".*TypeError.*: Expected a string.*" \ "check non-string key" # Test global/static blocks diff --git a/gdb/testsuite/gdb.python/py-breakpoint.exp b/gdb/testsuite/gdb.python/py-breakpoint.exp index 67da48d2f48..1d0e96a15dd 100644 --- a/gdb/testsuite/gdb.python/py-breakpoint.exp +++ b/gdb/testsuite/gdb.python/py-breakpoint.exp @@ -190,7 +190,7 @@ proc_with_prefix test_bkpt_deletion { } { gdb_py_test_silent_cmd "python dp1.delete()" \ "Delete Breakpoint" 0 gdb_test "python print (dp1.number)" \ - "RuntimeError: Breakpoint 2 is invalid.*" \ + "RuntimeError.*: Breakpoint 2 is invalid.*" \ "Check breakpoint invalidated" gdb_py_test_silent_cmd "python del_list = gdb.breakpoints()" \ "Get Breakpoint List" 0 @@ -275,7 +275,7 @@ proc_with_prefix test_bkpt_thread_and_inferior { } { gdb_test "python print(bp.thread)" "1" gdb_test "python print(bp.inferior)" "None" gdb_test "python bp.inferior = 1" \ - "RuntimeError: Cannot have both 'thread' and 'inferior' conditions on a breakpoint.*" + "RuntimeError.*: Cannot have both 'thread' and 'inferior' conditions on a breakpoint.*" gdb_test_no_output "python bp.thread = None" gdb_test_no_output "python bp.inferior = 1" \ "set the inferior now the thread has been cleared" @@ -289,7 +289,7 @@ proc_with_prefix test_bkpt_thread_and_inferior { } { gdb_test "python print(bp.thread)" "None" gdb_test "python print(bp.inferior)" "1" gdb_test "python bp.thread = 1" \ - "RuntimeError: Cannot have both 'thread' and 'inferior' conditions on a breakpoint.*" + "RuntimeError.*: Cannot have both 'thread' and 'inferior' conditions on a breakpoint.*" gdb_test_no_output "python bp.inferior = None" gdb_test_no_output "python bp.thread = 1" \ "set the thread now the inferior has been cleared" @@ -522,7 +522,7 @@ proc_with_prefix test_bkpt_eval_funcs { } { "end" "" gdb_test "python eval_bp2.stop = stop_func" \ - "RuntimeError: Only one stop condition allowed. There is currently a GDB.*" \ + "RuntimeError.*: Only one stop condition allowed. There is currently a GDB.*" \ "assign stop function to a breakpoint that has a condition" delete_breakpoints @@ -589,7 +589,7 @@ proc_with_prefix test_bkpt_temporary { } { ".*$srcfile:$ibp_location.*" gdb_test "python print (ibp.count)" "1" \ "Check temporary stop callback executed before deletion." - gdb_test "python print (ibp.temporary)" "RuntimeError: Breakpoint 2 is invalid.*" \ + gdb_test "python print (ibp.temporary)" "RuntimeError.*: Breakpoint 2 is invalid.*" \ "Check temporary breakpoint is deleted after being hit" gdb_test "info breakpoints" "No breakpoints or watchpoints.*" \ "Check info breakpoints shows temporary breakpoint is deleted" @@ -707,7 +707,7 @@ proc_with_prefix test_bkpt_explicit_loc {} { delete_breakpoints gdb_test "python bp1 = gdb.Breakpoint (line=bp1)" \ - "RuntimeError: Line keyword should be an integer or a string.*" \ + "RuntimeError.*: Line keyword should be an integer or a string.*" \ "set explicit breakpoint by invalid line type" delete_breakpoints @@ -736,7 +736,7 @@ proc_with_prefix test_bkpt_explicit_loc {} { delete_breakpoints gdb_test "python bp1 = gdb.Breakpoint (source=\"$srcfile\")" \ - "RuntimeError: Specifying a source must also include a line, label or function.*" \ + "RuntimeError.*: Specifying a source must also include a line, label or function.*" \ "set invalid explicit breakpoint by source only" gdb_test "python bp1 = gdb.Breakpoint (source=\"foo.c\", line=\"5\")" \ @@ -859,8 +859,8 @@ proc_with_prefix test_catchpoints {} { # the python api. gdb_test "python gdb.Breakpoint (\"syscall\", type=gdb.BP_CATCHPOINT)" \ [multi_line \ - "gdb.error: BP_CATCHPOINT not supported" \ - "Error while executing Python code\\."] \ + "gdb.error.*: BP_CATCHPOINT not supported" \ + "Error occurred in Python:.*"] \ "create a catchpoint via the api" # Setup a catchpoint. diff --git a/gdb/testsuite/gdb.python/py-connection.exp b/gdb/testsuite/gdb.python/py-connection.exp index fa995f19d3d..ca78b37c4f1 100644 --- a/gdb/testsuite/gdb.python/py-connection.exp +++ b/gdb/testsuite/gdb.python/py-connection.exp @@ -65,10 +65,10 @@ gdb_test "python print(conn.is_valid())" "False" "is_valid returns False" # Now check that accessing properties of the invalid connection cases # an error. gdb_test "python print(conn.num)" \ - "RuntimeError: Connection no longer exists\\.\r\n.*" + "RuntimeError.*: Connection no longer exists\\.\r\n.*" gdb_test "python print(conn.type)" \ - "RuntimeError: Connection no longer exists\\.\r\n.*" + "RuntimeError.*: Connection no longer exists\\.\r\n.*" gdb_test "python print(conn.description)" \ - "RuntimeError: Connection no longer exists\\.\r\n.*" + "RuntimeError.*: Connection no longer exists\\.\r\n.*" gdb_test "python print(conn.details)" \ - "RuntimeError: Connection no longer exists\\.\r\n.*" + "RuntimeError.*: Connection no longer exists\\.\r\n.*" diff --git a/gdb/testsuite/gdb.python/py-disasm.exp b/gdb/testsuite/gdb.python/py-disasm.exp index 0458b33c5a9..7c6f972a7e7 100644 --- a/gdb/testsuite/gdb.python/py-disasm.exp +++ b/gdb/testsuite/gdb.python/py-disasm.exp @@ -164,16 +164,16 @@ foreach plan $test_plans { with_test_prefix "DisassemblerResult errors" { gdb_test "python gdb.disassembler.DisassemblerResult(0, 'abc')" \ [multi_line \ - "ValueError: Length must be greater than 0." \ - "Error while executing Python code."] + "ValueError.*: Length must be greater than 0." \ + "Error occurred in Python.*"] gdb_test "python gdb.disassembler.DisassemblerResult(-1, 'abc')" \ [multi_line \ - "ValueError: Length must be greater than 0." \ - "Error while executing Python code."] + "ValueError.*: Length must be greater than 0." \ + "Error occurred in Python.*"] gdb_test "python gdb.disassembler.DisassemblerResult(1, '')" \ [multi_line \ - "ValueError: String must not be empty." \ - "Error while executing Python code."] + "ValueError.*: String must not be empty.*" \ + "Error occurred in Python.*"] } # Check that the architecture specific disassemblers can override the @@ -255,8 +255,8 @@ with_test_prefix "Bad DisassembleInfo creation" { gdb_test "python print(my_info.is_valid())" "True" gdb_test "python gdb.disassembler.builtin_disassemble(my_info)" \ [multi_line \ - "RuntimeError: DisassembleInfo is no longer valid\\." \ - "Error while executing Python code\\."] + "RuntimeError.*: DisassembleInfo is no longer valid\\." \ + "Error occurred in Python.*"] } # Some of the disassembler related types should not be sub-typed, @@ -274,8 +274,8 @@ with_test_prefix "check inheritance" { " pass" "" \ "end" \ [multi_line \ - "TypeError: type '${type_ptn}' is not an acceptable base type" \ - "Error while executing Python code\\."] + "TypeError.*: type '${type_ptn}' is not an acceptable base type" \ + "Error occurred in Python.*"] } } @@ -283,15 +283,15 @@ with_test_prefix "check inheritance" { # Test some error conditions when creating a DisassemblerResult object. gdb_test "python result = gdb.disassembler.DisassemblerResult()" \ [multi_line \ - "TypeError: [missing_arg_pattern length 1]" \ - "Error while executing Python code\\."] \ + "TypeError.*: [missing_arg_pattern length 1]" \ + "Error occurred in Python.*"] \ "try to create a DisassemblerResult without a length argument" foreach len {0 -1} { gdb_test "python result = gdb.disassembler.DisassemblerResult($len)" \ [multi_line \ - "ValueError: Length must be greater than 0\\." \ - "Error while executing Python code\\."] \ + "ValueError.*: Length must be greater than 0\\." \ + "Error occurred in Python.*"] \ "try to create a DisassemblerResult with length $len" } @@ -300,7 +300,7 @@ foreach len {0 -1} { foreach type {DisassemblerTextPart DisassemblerAddressPart} { gdb_test "python result = gdb.disassembler.${type}()" \ [multi_line \ - "RuntimeError: Cannot create instances of DisassemblerPart\\." \ - "Error while executing Python code\\."] \ + "RuntimeError.*: Cannot create instances of DisassemblerPart\\." \ + "Error occurred in Python.*"] \ "try to create an instance of ${type}" } diff --git a/gdb/testsuite/gdb.python/py-error.exp b/gdb/testsuite/gdb.python/py-error.exp index 58e8549453f..6eb9cc3d659 100644 --- a/gdb/testsuite/gdb.python/py-error.exp +++ b/gdb/testsuite/gdb.python/py-error.exp @@ -50,7 +50,12 @@ if {$test2 == ""} { set remote_python_file [gdb_remote_download host \ ${srcdir}/${subdir}/${testfile}.py] -# argc=LookupError: unknown encoding: IBM1047 -gdb_test "source $remote_python_file" "Traceback.*ClassName.*\r\nLookupError: unknown encoding: $charset" $test2 +# With the new way that "source" works, it isn't really possible for +# this to fail "correctly". Converting the filename to a Python +# unicode object will fail -- and, mysteriously, without setting a +# real exception. +gdb_test "source $remote_python_file" \ + "An error occurred in Python.*" \ + $test2 gdb_test "p 1" " = 1" "no delayed error" diff --git a/gdb/testsuite/gdb.python/py-finish-breakpoint.exp b/gdb/testsuite/gdb.python/py-finish-breakpoint.exp index 6b72ddb2186..c2a85b1237c 100644 --- a/gdb/testsuite/gdb.python/py-finish-breakpoint.exp +++ b/gdb/testsuite/gdb.python/py-finish-breakpoint.exp @@ -85,7 +85,7 @@ with_test_prefix "normal conditions" { gdb_test "finish" "main.*" "return to main()" gdb_test "python MyFinishBreakpoint (None, gdb.selected_frame ())" \ - "ValueError: \"FinishBreakpoint\" not meaningful in the outermost frame..*" \ + "ValueError.*: \"FinishBreakpoint\" not meaningful in the outermost frame..*" \ "check FinishBP not allowed in main" } diff --git a/gdb/testsuite/gdb.python/py-format-address.exp b/gdb/testsuite/gdb.python/py-format-address.exp index 06654d98954..8e7cf47e03a 100644 --- a/gdb/testsuite/gdb.python/py-format-address.exp +++ b/gdb/testsuite/gdb.python/py-format-address.exp @@ -84,27 +84,27 @@ gdb_test "python print(\"Got: \" + gdb.format_address($main_addr, None, None))" # Now forget the architecture, this should fail. gdb_test "python print(\"Got: \" + gdb.format_address($main_addr, inf.progspace))" \ [multi_line \ - "ValueError: The architecture and progspace arguments must both be supplied" \ - "Error while executing Python code\\."] \ + "ValueError.*: The architecture and progspace arguments must both be supplied" \ + "Error occurred in Python.*"] \ "gdb.format_address passing program space only" gdb_test "python print(\"Got: \" + gdb.format_address($main_addr, inf.progspace, None))" \ [multi_line \ - "ValueError: The architecture and progspace arguments must both be supplied" \ - "Error while executing Python code\\."] \ + "ValueError.*: The architecture and progspace arguments must both be supplied" \ + "Error occurred in Python.*"] \ "gdb.format_address passing real program space, but architecture is None" # Now skip the program space argument. gdb_test "python print(\"Got: \" + gdb.format_address($main_addr, architecture=inf.architecture()))" \ [multi_line \ - "ValueError: The architecture and progspace arguments must both be supplied" \ - "Error while executing Python code\\."] \ + "ValueError.*: The architecture and progspace arguments must both be supplied" \ + "Error occurred in Python.*"] \ "gdb.format_address passing architecture only" gdb_test "python print(\"Got: \" + gdb.format_address($main_addr, None, inf.architecture()))" \ [multi_line \ - "ValueError: The architecture and progspace arguments must both be supplied" \ - "Error while executing Python code\\."] \ + "ValueError.*: The architecture and progspace arguments must both be supplied" \ + "Error occurred in Python.*"] \ "gdb.format_address passing real architecture, but progspace is None" # Now, before we add a second inferior, lets just check we can format @@ -155,14 +155,14 @@ gdb_test "python print(\"Got: \" + gdb.format_address($bar_addr, inf2.progspace, # Try pasing incorrect object types for program space and architecture. gdb_test "python print(\"Got: \" + gdb.format_address($bar_addr, inf2.progspace, inf2.progspace))" \ [multi_line \ - "TypeError: The architecture argument is not a gdb.Architecture object" \ - "Error while executing Python code\\."] \ + "TypeError.*: The architecture argument is not a gdb.Architecture object" \ + "Error occurred in Python.*"] \ "gdb.format_address pass wrong object type for architecture" gdb_test "python print(\"Got: \" + gdb.format_address($bar_addr, inf2.architecture(), inf2.architecture()))" \ [multi_line \ - "TypeError: The progspace argument is not a gdb.Progspace object" \ - "Error while executing Python code\\."] \ + "TypeError.*: The progspace argument is not a gdb.Progspace object" \ + "Error occurred in Python.*"] \ "gdb.format_address pass wrong object type for progspace" # Now invalidate inferior 2's program space, and try using that. @@ -171,6 +171,6 @@ gdb_test "python arch = inf2.architecture()" gdb_test "remove-inferior 2" gdb_test "python print(\"Got: \" + gdb.format_address($bar_addr, pspace, arch))" \ [multi_line \ - "ValueError: The progspace argument is not valid" \ - "Error while executing Python code\\."] \ + "ValueError.*: The progspace argument is not valid" \ + "Error occurred in Python.*"] \ "gdb.format_address called with an invalid program space" diff --git a/gdb/testsuite/gdb.python/py-format-string.exp b/gdb/testsuite/gdb.python/py-format-string.exp index cd434b8fd4b..0c70ad562c7 100644 --- a/gdb/testsuite/gdb.python/py-format-string.exp +++ b/gdb/testsuite/gdb.python/py-format-string.exp @@ -1102,22 +1102,22 @@ proc_with_prefix test_invalid_args {} { check_format_string \ "a_point_t" \ "12" \ - "TypeError: format_string\\(\\) takes 0 positional arguments but 1 were given.*" + "TypeError.*: format_string\\(\\) takes 0 positional arguments but 1 were given.*" check_format_string \ "a_point_t" \ "invalid=True" \ - "TypeError: 'invalid' is an invalid keyword argument for this function.*" + "TypeError.*: 'invalid' is an invalid keyword argument for this function.*" check_format_string \ "a_point_t" \ "raw='hello'" \ - "TypeError: argument 1 must be bool, not str.*" + "TypeError.*: argument 1 must be bool, not str.*" check_format_string \ "a_point_t" \ "format='xd'" \ - "ValueError: a single character is required.*" + "ValueError.*: a single character is required.*" } # Check the styling argument to format_string. This function needs to diff --git a/gdb/testsuite/gdb.python/py-frame.exp b/gdb/testsuite/gdb.python/py-frame.exp index 110ddf24480..8f776eb08a5 100644 --- a/gdb/testsuite/gdb.python/py-frame.exp +++ b/gdb/testsuite/gdb.python/py-frame.exp @@ -77,25 +77,25 @@ gdb_test "python print (bf1.read_var(\"i\", sb).type)" "int" "test int i" # Test what happens when we provide a block of the wrong type. gdb_test "python print (bf1.read_var(\"i\", \"some_block\"))" \ [multi_line \ - "TypeError: argument 2 must be gdb\\.Block, not str" \ - "Error while executing Python code\\."] \ + "TypeError.*: argument 2 must be gdb\\.Block, not str" \ + "Error occurred in Python.*"] \ "check invalid block type error" gdb_test "python print (bf1.read_var(block = \"some_block\", variable = \"i\"))" \ [multi_line \ - "TypeError: argument 2 must be gdb\\.Block, not str" \ - "Error while executing Python code\\."] \ + "TypeError.*: argument 2 must be gdb\\.Block, not str" \ + "Error occurred in Python.*"] \ "check invalid block type error when named args are used" # Test what happens when we provide a variable of the wrong type. gdb_test "python print (bf1.read_var(None))" \ [multi_line \ - "TypeError: argument 1 must be gdb\\.Symbol or str, not NoneType" \ - "Error while executing Python code\\."] \ + "TypeError.*: argument 1 must be gdb\\.Symbol or str, not NoneType" \ + "Error occurred in Python.*"] \ "check read_var error when variable is None" gdb_test "python print (bf1.read_var(sb))" \ [multi_line \ - "TypeError: argument 1 must be gdb\\.Symbol or str, not gdb\\.Block" \ - "Error while executing Python code\\."] \ + "TypeError.*: argument 1 must be gdb\\.Symbol or str, not gdb\\.Block" \ + "Error occurred in Python.*"] \ "check read_var error when variable is a gdb.Block" gdb_breakpoint "f2" @@ -141,7 +141,7 @@ gdb_test "python print ('result = %s' % f0.pc ())" " = \[0-9\]+" "test Frame.pc" gdb_test "python print ('result = %s' % (f0.older () == f1))" " = True" "test Frame.older" gdb_test "python print ('result = %s' % (f1.newer () == f0))" " = True" "test Frame.newer" gdb_test "python print ('result = %s' % f0.read_var ('variable_which_surely_doesnt_exist'))" \ - "ValueError: Variable 'variable_which_surely_doesnt_exist' not found.*Error while executing Python code." \ + "ValueError.*: Variable 'variable_which_surely_doesnt_exist' not found.*Error occurred in Python.*" \ "test Frame.read_var - error" gdb_test "python print ('result = %s' % f0.read_var ('a'))" " = 1" "test Frame.read_var - success" diff --git a/gdb/testsuite/gdb.python/py-inferior.exp b/gdb/testsuite/gdb.python/py-inferior.exp index 2968e027812..c14f2d2796c 100644 --- a/gdb/testsuite/gdb.python/py-inferior.exp +++ b/gdb/testsuite/gdb.python/py-inferior.exp @@ -122,8 +122,8 @@ gdb_test "python print(worker_thread._user_attribute)" "123" \ "read back user defined attribute" gdb_test "python print(main_thread._user_attribute)" \ [multi_line \ - "AttributeError: 'gdb\\.InferiorThread' object has no attribute '_user_attribute'" \ - "Error while executing Python code\\."] \ + "AttributeError.*: 'gdb\\.InferiorThread' object has no attribute '_user_attribute'" \ + "Error occurred in Python.*"] \ "attempt to read non-existent user defined attribute" # Proceed to the next test. @@ -162,8 +162,8 @@ set num [add_inferior] # but that the first inferior does still have the attribute. gdb_test "python print(gdb.inferiors()\[1\]._user_attr)" \ [multi_line \ - "AttributeError: 'gdb\\.Inferior' object has no attribute '_user_attr'" \ - "Error while executing Python code\\."] \ + "AttributeError.*: 'gdb\\.Inferior' object has no attribute '_user_attr'" \ + "Error occurred in Python.*"] \ "check new inferior doesn't have user defined attribute" gdb_test "python print(gdb.inferiors()\[0\]._user_attr)" \ "123" "read back user defined attribute again" @@ -366,21 +366,21 @@ with_test_prefix "is_valid" { # Test that other properties and methods handle the removed inferior # correctly. gdb_test "python print (inf_list\[1\].num)" \ - "RuntimeError: Inferior no longer exists.*" + "RuntimeError.*: Inferior no longer exists.*" gdb_test "python print (inf_list\[1\].connection_num)" \ - "RuntimeError: Inferior no longer exists.*" + "RuntimeError.*: Inferior no longer exists.*" gdb_test "python print (inf_list\[1\].connection)" \ - "RuntimeError: Inferior no longer exists.*" + "RuntimeError.*: Inferior no longer exists.*" gdb_test "python print (inf_list\[1\].pid)" \ - "RuntimeError: Inferior no longer exists.*" + "RuntimeError.*: Inferior no longer exists.*" gdb_test "python print (inf_list\[1\].was_attached)" \ - "RuntimeError: Inferior no longer exists.*" + "RuntimeError.*: Inferior no longer exists.*" gdb_test "python print (inf_list\[1\].progspace)" \ - "RuntimeError: Inferior no longer exists.*" + "RuntimeError.*: Inferior no longer exists.*" gdb_test "python print (inf_list\[1\].threads ())" \ - "RuntimeError: Inferior no longer exists.*" + "RuntimeError.*: Inferior no longer exists.*" gdb_test "python print (inf_list\[1\].thread_from_thread_handle (1))" \ - "RuntimeError: Inferior no longer exists.*" + "RuntimeError.*: Inferior no longer exists.*" } # Test gdb.selected_inferior() diff --git a/gdb/testsuite/gdb.python/py-lazy-string.exp b/gdb/testsuite/gdb.python/py-lazy-string.exp index 8e7eca846b0..a00f47b1e2a 100644 --- a/gdb/testsuite/gdb.python/py-lazy-string.exp +++ b/gdb/testsuite/gdb.python/py-lazy-string.exp @@ -40,13 +40,13 @@ gdb_test "python print (nullstr.length)" "0" "null lazy string length" gdb_test "python print (nullstr.address)" "0" "null lazy string address" gdb_test "python print (nullstr.type)" "const char \\*" "null lazy string type" gdb_test "python print(nullstr.value())" \ - "gdb.MemoryError: Cannot create a value from NULL.*Error while executing Python code." \ + "gdb.MemoryError.*: Cannot create a value from NULL.*Error occurred in Python.*" \ "create value from NULL" gdb_test "python print(null.lazy_string(length=3).value())" \ - "gdb.MemoryError: Cannot create a lazy string with address 0x0, and a non-zero length.*Error while executing Python code." \ + "gdb.MemoryError.*: Cannot create a lazy string with address 0x0, and a non-zero length.*Error occurred in Python.*" \ "null lazy string with non-zero length" gdb_test "python print(null.lazy_string(length=-2))" \ - "ValueError: Invalid length.*Error while executing Python code." \ + "ValueError.*: Invalid length.*Error occurred in Python.*" \ "bad length" foreach var_spec { { "ptr" "pointer" "const char \\*" -1 } \ diff --git a/gdb/testsuite/gdb.python/py-mi-cmd.exp b/gdb/testsuite/gdb.python/py-mi-cmd.exp index d9fba23b39b..28c71cd75f3 100644 --- a/gdb/testsuite/gdb.python/py-mi-cmd.exp +++ b/gdb/testsuite/gdb.python/py-mi-cmd.exp @@ -70,7 +70,7 @@ mi_gdb_test "-pycmd bk2" \ mi_gdb_test "-pycmd bk3" \ [multi_line \ - "&\"TypeError: __repr__ returned non-string \\(type BadKey\\)..\"" \ + "&\"TypeError.*: __repr__ returned non-string \\(type BadKey\\)..\"" \ "\\^error,msg=\"Error occurred in Python: __repr__ returned non-string \\(type BadKey\\)\""] \ "-pycmd bk3" @@ -156,23 +156,23 @@ mi_gdb_test "-pycmd-new int" \ "-pycmd-new int - defined from MI" mi_gdb_test "python pycmd1('')" \ - ".*&\"ValueError: MI command name is empty\\...\".*\\^error,msg=\"Error while executing Python code\\.\"" \ + ".*&\"ValueError.*: MI command name is empty\\...\".*\\^error,msg=\"Error occurred in Python.*\"" \ "empty MI command name" mi_gdb_test "python pycmd1('-')" \ [multi_line \ ".*" \ - "&\"ValueError: MI command name does not start with '-' followed by at least one letter or digit\\...\"" \ - "&\"Error while executing Python code\\...\"" \ - "\\^error,msg=\"Error while executing Python code\\.\""] \ + "&\"ValueError.*: MI command name does not start with '-' followed by at least one letter or digit\\...\"" \ + "&\"Error occurred in Python.*..\"" \ + "\\^error,msg=\"Error occurred in Python.*\""] \ "invalid MI command name" mi_gdb_test "python pycmd1('-bad-character-@')" \ [multi_line \ ".*" \ - "&\"ValueError: MI command name contains invalid character: @\\...\"" \ - "&\"Error while executing Python code\\...\"" \ - "\\^error,msg=\"Error while executing Python code\\.\""] \ + "&\"ValueError.*: MI command name contains invalid character: @\\...\"" \ + "&\"Error occurred in Python.*..\"" \ + "\\^error,msg=\"Error occurred in Python.*\""] \ "invalid character in MI command name" mi_gdb_test "python cmd=pycmd1('-abc')" \ @@ -258,9 +258,9 @@ mi_gdb_test "-aa" \ mi_gdb_test "python aa.__init__('-bb', 'message three', 'zzz')" \ [multi_line \ ".*" \ - "&\"ValueError: can't reinitialize object with a different command name..\"" \ - "&\"Error while executing Python code\\...\"" \ - "\\^error,msg=\"Error while executing Python code\\.\""] \ + "&\"ValueError.*: can't reinitialize object with a different command name..\"" \ + "&\"Error occurred in Python.*..\"" \ + "\\^error,msg=\"Error occurred in Python.*\""] \ "attempt to reinitialise aa variable to a new command name" mi_gdb_test "-aa" \ @@ -274,9 +274,9 @@ mi_gdb_test "python aa.installed = False" \ mi_gdb_test "python aa.__init__('-bb', 'message three', 'zzz')" \ [multi_line \ ".*" \ - "&\"ValueError: can't reinitialize object with a different command name..\"" \ - "&\"Error while executing Python code\\...\"" \ - "\\^error,msg=\"Error while executing Python code\\.\""] \ + "&\"ValueError.*: can't reinitialize object with a different command name..\"" \ + "&\"Error occurred in Python.*..\"" \ + "\\^error,msg=\"Error occurred in Python.*\""] \ "attempt to reinitialise aa variable to a new command name while uninstalled" mi_gdb_test "python aa.__init__('-aa', 'message three', 'zzz')" \ @@ -299,7 +299,7 @@ mi_gdb_test "python no_invoke('-no-invoke')" ".*\\^done" \ mi_gdb_test "-no-invoke" \ [multi_line \ ".*" \ - "&\"AttributeError: 'no_invoke' object has no attribute 'invoke'..\"" \ + "&\"AttributeError.*: 'no_invoke' object has no attribute 'invoke'..\"" \ "\\^error,msg=\"Error occurred in Python: 'no_invoke' object has no attribute 'invoke'\""] \ "execute -no-invoke command, which is missing the invoke method" @@ -312,14 +312,14 @@ mi_gdb_test "python delattr(no_invoke, 'invoke')" ".*\\^done" mi_gdb_test "-hello" \ [multi_line \ ".*" \ - "&\"AttributeError: 'no_invoke' object has no attribute 'invoke'..\"" \ + "&\"AttributeError.*: 'no_invoke' object has no attribute 'invoke'..\"" \ "\\^error,msg=\"Error occurred in Python: 'no_invoke' object has no attribute 'invoke'\""] \ "execute -hello command, that had its invoke method removed" mi_gdb_test "python cmd.invoke = 'string'" ".*\\^done" mi_gdb_test "-hello" \ [multi_line \ ".*" \ - "&\"TypeError: 'str' object is not callable..\"" \ + "&\"TypeError.*: 'str' object is not callable..\"" \ "\\^error,msg=\"Error occurred in Python: 'str' object is not callable\""] \ "execute command with invoke set to a string" @@ -327,9 +327,9 @@ mi_gdb_test "-hello" \ mi_gdb_test "python cmd = pycmd2('-data-disassemble')" \ [multi_line \ ".*" \ - "&\"RuntimeError: unable to add command, name is already in use..\"" \ - "&\"Error while executing Python code\\...\"" \ - "\\^error,msg=\"Error while executing Python code\\.\""] \ + "&\"RuntimeError.*: unable to add command, name is already in use..\"" \ + "&\"Error occurred in Python.*..\"" \ + "\\^error,msg=\"Error occurred in Python.*\""] \ "try to register a command that replaces -data-disassemble" diff --git a/gdb/testsuite/gdb.python/py-missing-debug.exp b/gdb/testsuite/gdb.python/py-missing-debug.exp index 0aa4aaa010b..d1eef34c3f3 100644 --- a/gdb/testsuite/gdb.python/py-missing-debug.exp +++ b/gdb/testsuite/gdb.python/py-missing-debug.exp @@ -201,8 +201,8 @@ proc check_bad_name {name} { set name_re [string_to_regexp $name] set re \ [multi_line \ - "ValueError: invalid character '.' in handler name: $name_re" \ - "Error while executing Python code\\."] + "ValueError.*: invalid character '.' in handler name: $name_re" \ + "Error occurred in Python.*"] gdb_test "python register(\"$name\")" $re \ "check that '$name' is not accepted" @@ -442,13 +442,13 @@ with_test_prefix "check handler replacement" { # the same name. gdb_test "python gdb.missing_debug.register_handler(pspace, log_handler(\"Foo\"))" \ [multi_line \ - "RuntimeError: Handler Foo already exists\\." \ - "Error while executing Python code\\."] + "RuntimeError.*: Handler Foo already exists\\." \ + "Error occurred in Python.*"] gdb_test "python gdb.missing_debug.register_handler(handler=log_handler(\"Foo\"), locus=pspace)" \ [multi_line \ - "RuntimeError: Handler Foo already exists\\." \ - "Error while executing Python code\\."] + "RuntimeError.*: Handler Foo already exists\\." \ + "Error occurred in Python.*"] # And now try again, but this time with 'replace=True', we # shouldn't get an error in this case. @@ -464,8 +464,8 @@ with_test_prefix "check handler replacement" { gdb_test "python gdb.missing_debug.register_handler(pspace, log_handler(\"Foo\"))" \ [multi_line \ - "RuntimeError: Handler Foo already exists\\." \ - "Error while executing Python code\\."] \ + "RuntimeError.*: Handler Foo already exists\\." \ + "Error occurred in Python.*"] \ "still get an error when handler is disabled" gdb_test_no_output \ diff --git a/gdb/testsuite/gdb.python/py-objfile.exp b/gdb/testsuite/gdb.python/py-objfile.exp index 1ddc3ddab36..2f5b7752b43 100644 --- a/gdb/testsuite/gdb.python/py-objfile.exp +++ b/gdb/testsuite/gdb.python/py-objfile.exp @@ -30,7 +30,7 @@ if {![runto_main]} { return 0 } -set python_error_text "Error while executing Python code\\." +set python_error_text "Error occurred in Python.*" gdb_py_test_silent_cmd "python sym = gdb.lookup_symbol(\"some_var\")" \ "Find a symbol in objfile" 1 diff --git a/gdb/testsuite/gdb.python/py-parameter.exp b/gdb/testsuite/gdb.python/py-parameter.exp index 94702f42816..de524f49ad6 100644 --- a/gdb/testsuite/gdb.python/py-parameter.exp +++ b/gdb/testsuite/gdb.python/py-parameter.exp @@ -342,7 +342,7 @@ proc_with_prefix test_gdb_parameter { } { } { clean_restart - set param_range_error ".*gdb.error: integer -1 out of range.*" + set param_range_error ".*gdb.error.*: integer -1 out of range.*" switch -- $param { "listsize" { set param_get_zero None @@ -438,8 +438,8 @@ proc_with_prefix test_integer_parameter { } { "test_param_$kind = TestNodocParam ('test-$kind')" "" \ "end" - set param_range_error "RuntimeError: Range exceeded.*" - set param_integer_error "RuntimeError: The value must be integer.*" + set param_range_error "RuntimeError.*: Range exceeded.*" + set param_integer_error "RuntimeError.*: The value must be integer.*" switch -- $kind { PARAM_UINTEGER { set param_get_zero None @@ -610,13 +610,13 @@ proc_with_prefix test_ambiguous_parameter {} { # Test ambiguous names. gdb_test "python print(gdb.parameter('test-ambiguou'))" \ - "Parameter .* is ambiguous.*Error while executing Python code." + "Parameter .* is ambiguous.*Error occurred in Python.*" gdb_test "python print(gdb.parameter('test-ambiguous-'))" \ - "Parameter .* is ambiguous.*Error while executing Python code." + "Parameter .* is ambiguous.*Error occurred in Python.*" gdb_test "python print(gdb.parameter('test-ambiguous-v'))" \ - "Parameter .* is ambiguous.*Error while executing Python code." + "Parameter .* is ambiguous.*Error occurred in Python.*" gdb_test "python print(gdb.parameter('test-ambiguous-value-1a'))" \ - "Could not find parameter.*Error while executing Python code." + "Could not find parameter.*Error occurred in Python.*" } test_directories diff --git a/gdb/testsuite/gdb.python/py-pp-registration.exp b/gdb/testsuite/gdb.python/py-pp-registration.exp index 68599d67a16..4bfdf5e5612 100644 --- a/gdb/testsuite/gdb.python/py-pp-registration.exp +++ b/gdb/testsuite/gdb.python/py-pp-registration.exp @@ -102,7 +102,7 @@ with_test_prefix "replace" { gdb_test_no_output "py gdb.printing.register_pretty_printer(gdb, lookup_function_lookup_test)" gdb_test_no_output "py gdb.printing.register_pretty_printer(progspace, my_pretty_printer1)" gdb_test "py gdb.printing.register_pretty_printer(progspace, my_pretty_printer2, replace=False)" \ - "RuntimeError: pretty-printer already registered: pp-test\r\nError while executing Python code." + "RuntimeError.*: pretty-printer already registered: pp-test\r\nError occurred in Python.*" with_test_prefix "test printers 1" { test_printers "s1" diff --git a/gdb/testsuite/gdb.python/py-progspace-events.exp b/gdb/testsuite/gdb.python/py-progspace-events.exp index 47a9985317e..95e4ca8da0b 100644 --- a/gdb/testsuite/gdb.python/py-progspace-events.exp +++ b/gdb/testsuite/gdb.python/py-progspace-events.exp @@ -107,7 +107,7 @@ set warning_msg \ gdb_test "step" \ [multi_line \ - "^FreeProgspaceEvent: (?:\r\n$warning_msg)*" \ + "^FreeProgspaceEvent.*: (?:\r\n$warning_msg)*" \ "do_parent_stuff \\(\\) at \[^\r\n\]+" \ "$decimal\\s+\[^\r\n\]+"] diff --git a/gdb/testsuite/gdb.python/py-progspace.exp b/gdb/testsuite/gdb.python/py-progspace.exp index f76e1f9359a..0ae5b5673d8 100644 --- a/gdb/testsuite/gdb.python/py-progspace.exp +++ b/gdb/testsuite/gdb.python/py-progspace.exp @@ -55,8 +55,8 @@ gdb_test "python print (progspace.random_attribute)" "42" \ # Check that we can't create new (invalid) gdb.Progspace objects. gdb_test "python gdb.Progspace()" \ - [multi_line "TypeError: cannot create 'gdb.Progspace' instances" \ - "Error while executing Python code\\."] \ + [multi_line "TypeError.*: cannot create 'gdb.Progspace' instances" \ + "Error occurred in Python.*"] \ "check for error when calling gdb.Progspace() directly" if {![runto_main]} { @@ -111,7 +111,7 @@ gdb_py_test_silent_cmd "python progspace2 = gdb.current_progspace()" \ gdb_test "inferior 1" "Switching to inferior 1.*" gdb_test_no_output "remove-inferiors 2" gdb_test "python print (progspace2.objfiles ())" \ - "RuntimeError: Program space no longer exists.*" + "RuntimeError.*: Program space no longer exists.*" gdb_test "python print (progspace2.symbol_file)" \ - "RuntimeError: Program space no longer exists.*" + "RuntimeError.*: Program space no longer exists.*" diff --git a/gdb/testsuite/gdb.python/py-record-btrace.exp b/gdb/testsuite/gdb.python/py-record-btrace.exp index 71ff52ed137..fba0b98f794 100644 --- a/gdb/testsuite/gdb.python/py-record-btrace.exp +++ b/gdb/testsuite/gdb.python/py-record-btrace.exp @@ -34,12 +34,12 @@ with_test_prefix "no or double record" { gdb_test_no_output "python gdb.start_recording(\"btrace\")" gdb_test "python gdb.start_recording(\"btrace\")" \ - ".*gdb\.error: The process is already being recorded\..*" \ + ".*gdb\.error.*: The process is already being recorded\..*" \ "already recording" gdb_test_no_output "python gdb.stop_recording()" "first" gdb_test "python gdb.stop_recording()" \ - ".*gdb\.error: No recording is currently active\..*" "second" + ".*gdb\.error.*: No recording is currently active\..*" "second" } with_test_prefix "preopened record btrace" { diff --git a/gdb/testsuite/gdb.python/py-record-full.exp b/gdb/testsuite/gdb.python/py-record-full.exp index 19497fb3cd1..da38d1cab6b 100644 --- a/gdb/testsuite/gdb.python/py-record-full.exp +++ b/gdb/testsuite/gdb.python/py-record-full.exp @@ -34,12 +34,12 @@ with_test_prefix "no or double record" { gdb_test_no_output "python gdb.start_recording(\"full\")" gdb_test "python gdb.start_recording(\"full\")" \ - ".*gdb\.error: The process is already being recorded\..*" \ + ".*gdb\.error.*: The process is already being recorded\..*" \ "already recording" gdb_test_no_output "python gdb.stop_recording()" "first" gdb_test "python gdb.stop_recording()" \ - ".*gdb\.error: No recording is currently active\..*" "second" + ".*gdb\.error.*: No recording is currently active\..*" "second" } with_test_prefix "preopened record full" { diff --git a/gdb/testsuite/gdb.python/py-template.exp b/gdb/testsuite/gdb.python/py-template.exp index fbb745506e2..bba80e3b870 100644 --- a/gdb/testsuite/gdb.python/py-template.exp +++ b/gdb/testsuite/gdb.python/py-template.exp @@ -50,7 +50,7 @@ proc test_template_arg {exefile type} { gdb_test "python print (foo.type.template_argument(0))" $t $type gdb_test "python print(foo.type.template_argument(-1))" \ - "Template argument number must be non-negative\r\nError while executing Python code." \ + "Template argument number must be non-negative\r\nError occurred in Python.*" \ "negative template argument number in template test of $type" } diff --git a/gdb/testsuite/gdb.python/py-thrhandle.exp b/gdb/testsuite/gdb.python/py-thrhandle.exp index 60399774b1b..939f0a86f48 100644 --- a/gdb/testsuite/gdb.python/py-thrhandle.exp +++ b/gdb/testsuite/gdb.python/py-thrhandle.exp @@ -90,7 +90,7 @@ gdb_test "python print(gdb.selected_inferior().thread_from_handle(gdb.parse_and_ # We should see an exception when passing an object of the wrong type. gdb_test "python print(gdb.selected_inferior().thread_from_handle(gdb.lookup_symbol('main')))" \ - ".*TypeError: Argument 'handle' must be a thread handle object.*" \ + ".*TypeError.*: Argument 'handle' must be a thread handle object.*" \ "TypeError when passing a symbol object to thread_from_handle" # We should see an exception when passing too large of an object. diff --git a/gdb/testsuite/gdb.python/py-type.exp b/gdb/testsuite/gdb.python/py-type.exp index 1e9e7152f78..74e123441c4 100644 --- a/gdb/testsuite/gdb.python/py-type.exp +++ b/gdb/testsuite/gdb.python/py-type.exp @@ -121,10 +121,10 @@ proc test_fields {lang} { gdb_test "python print (not not st.type)" "True" "check conversion to bool" # Test rejection of mapping operations on scalar types - gdb_test "python print (len (st.type\['a'\].type))" "TypeError: Type is not a structure, union, enum, or function type.*" - gdb_test "python print (st.type\['a'\].type.has_key ('x'))" "TypeError: Type is not a structure, union, enum, or function type.*" - gdb_test "python print (st.type\['a'\].type\['x'\])" "TypeError: Type is not a structure, union, enum, or function type.*" - gdb_test "python print (st.type\['a'\].type.keys ())" "TypeError: Type is not a structure, union, enum, or function type.*" + gdb_test "python print (len (st.type\['a'\].type))" "TypeError.*: Type is not a structure, union, enum, or function type.*" + gdb_test "python print (st.type\['a'\].type.has_key ('x'))" "TypeError.*: Type is not a structure, union, enum, or function type.*" + gdb_test "python print (st.type\['a'\].type\['x'\])" "TypeError.*: Type is not a structure, union, enum, or function type.*" + gdb_test "python print (st.type\['a'\].type.keys ())" "TypeError.*: Type is not a structure, union, enum, or function type.*" # Test conversion to bool on scalar types gdb_test "python print (not not st.type\['a'\].type)" "True" @@ -167,7 +167,7 @@ proc test_fields {lang} { gdb_test "python print (gdb.parse_and_eval ('a_function').type.fields ()\[1\].type)" "char" # Test calling `fields` on a non-aggregate type. - gdb_test "python gdb.lookup_type('int').fields()" "TypeError: Type is not a structure, union, enum, or function type.*" + gdb_test "python gdb.lookup_type('int').fields()" "TypeError.*: Type is not a structure, union, enum, or function type.*" } } @@ -224,7 +224,7 @@ proc test_range {} { # Test where a range does not exist. gdb_py_test_silent_cmd "print (st)" "print value (st)" 1 gdb_py_test_silent_cmd "python st = gdb.history (0)" "get value (st) from history" 1 - gdb_test "python print (st.type.range())" "RuntimeError: This type does not have a range.*" "check range for non ranged type." + gdb_test "python print (st.type.range())" "RuntimeError.*: This type does not have a range.*" "check range for non ranged type." } } } @@ -264,7 +264,7 @@ proc test_template {} { proc test_is_signed {lang} { if {$lang == "c++"} { gdb_test "python print(gdb.parse_and_eval ('c').type.is_signed)" \ - "ValueError: Type must be a scalar type.*" + "ValueError.*: Type must be a scalar type.*" gdb_test "python print(gdb.parse_and_eval ('&c').type.is_signed == False)" "True" } @@ -274,13 +274,13 @@ proc test_is_signed {lang} { gdb_test "python print(gdb.parse_and_eval ('ss.x').type.is_signed == True)" "True" gdb_test "python print(gdb.parse_and_eval ('ss').type.is_signed)" \ - "ValueError: Type must be a scalar type.*" + "ValueError.*: Type must be a scalar type.*" gdb_test "python print(gdb.parse_and_eval ('uu').type.is_signed)" \ - "ValueError: Type must be a scalar type.*" + "ValueError.*: Type must be a scalar type.*" gdb_test "python print(gdb.parse_and_eval ('uu.i').type.is_signed == True)" "True" gdb_test "python print(gdb.parse_and_eval ('uu.f').type.is_signed == True)" "True" gdb_test "python print(gdb.parse_and_eval ('uu.a').type.is_signed)" \ - "ValueError: Type must be a scalar type.*" + "ValueError.*: Type must be a scalar type.*" gdb_test "python print(gdb.parse_and_eval ('&ss.x').type.is_signed == False)" "True" gdb_test "python print(gdb.parse_and_eval ('&uu').type.is_signed == False)" "True" diff --git a/gdb/testsuite/gdb.python/py-unwind.exp b/gdb/testsuite/gdb.python/py-unwind.exp index 1f88be0ac97..d5efc0216cf 100644 --- a/gdb/testsuite/gdb.python/py-unwind.exp +++ b/gdb/testsuite/gdb.python/py-unwind.exp @@ -97,8 +97,8 @@ check_for_fixed_backtrace "check backtrace after flush" # output to be sure. gdb_test "python global_test_unwinder.enabled = \"off\"" \ [multi_line \ - "TypeError: incorrect type for enabled attribute: " \ - "Error while executing Python code\\."] + "TypeError.*: incorrect type for enabled attribute: " \ + "Error occurred in Python.*"] check_info_unwinder "info unwinder after failed disable" on # While we're doing silly stuff, lets try to change the name of this @@ -109,8 +109,8 @@ set pattern_1 "can't set attribute(?: 'name')?" set pattern_2 "property 'name' of 'TestUnwinder' object has no setter" gdb_test "python global_test_unwinder.name = \"foo\"" \ [multi_line \ - "AttributeError: (?:${pattern_1}|${pattern_2})" \ - "Error while executing Python code\\."] + "AttributeError.*: (?:${pattern_1}|${pattern_2})" \ + "Error occurred in Python.*"] check_info_unwinder "info unwinder after failed name change" on # Now actually disable the unwinder by manually adjusting the @@ -149,8 +149,8 @@ gdb_test "python print(read_register_error)" "Bad register" \ # Try to create an unwinder object with a non-string name. gdb_test "python obj = simple_unwinder(True)" \ [multi_line \ - "TypeError: incorrect type for name: " \ - "Error while executing Python code\\."] + "TypeError.*: incorrect type for name: " \ + "Error occurred in Python.*"] # Now register the simple_unwinder with a valid name, and use the # unwinder to capture a PendingFrame object. @@ -195,8 +195,8 @@ foreach cmd {"pf.read_register(\"pc\")" \ "pf.function()" } { gdb_test "python $cmd" \ [multi_line \ - "ValueError: gdb\\.PendingFrame is invalid\\." \ - "Error while executing Python code\\."] + "ValueError.*: gdb\\.PendingFrame is invalid\\." \ + "Error occurred in Python.*"] } # Turn on the useful unwinder so we have the full backtrace again, and @@ -265,11 +265,11 @@ gdb_test_multiline "Sub-class gdb.UnwindInfo " \ " pass" "" \ "end" \ [multi_line \ - "TypeError: type 'gdb\\.UnwindInfo' is not an acceptable base type" \ - "Error while executing Python code\\."] + "TypeError.*: type 'gdb\\.UnwindInfo' is not an acceptable base type" \ + "Error occurred in Python.*"] # Check we can't directly instantiate a gdb.UnwindInfo. gdb_test "python uw = gdb.UnwindInfo()" \ [multi_line \ - "TypeError: cannot create 'gdb\\.UnwindInfo' instances" \ - "Error while executing Python code\\."] + "TypeError.*: cannot create 'gdb\\.UnwindInfo' instances" \ + "Error occurred in Python.*"] diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp index ff6b8b931f4..aa674e8aa0d 100644 --- a/gdb/testsuite/gdb.python/py-value.exp +++ b/gdb/testsuite/gdb.python/py-value.exp @@ -159,7 +159,7 @@ proc test_value_numeric_ops {} { } gdb_test_multiple "python print ('result = ' + str(i+gdb.Value('foo')))" "catch throw of GDB error" { - -re "Traceback.*$gdb_prompt $" {pass "catch throw of GDB error"} + -re "Error occurred in Python.*$gdb_prompt $" {pass "catch throw of GDB error"} -re "result = .*$gdb_prompt $" {fail "catch throw of GDB error"} -re "$gdb_prompt $" {fail "catch throw of GDB error"} } @@ -270,7 +270,7 @@ proc test_value_in_inferior {} { if {$can_read_0} { untested $test } else { - gdb_test "python print (gdb.parse_and_eval('*(int*)0'))" "gdb.MemoryError: Cannot access memory at address 0x0.*" $test + gdb_test "python print (gdb.parse_and_eval('*(int*)0'))" "gdb.MemoryError.*: Cannot access memory at address 0x0.*" $test } # Test Python lazy value handling @@ -281,10 +281,10 @@ proc test_value_in_inferior {} { gdb_test "python inval = gdb.parse_and_eval('*(int*)0')" gdb_test "python print (inval.is_lazy)" "True" gdb_test "python inval2 = inval+1" \ - "gdb.MemoryError: Cannot access memory at address 0x0.*" \ + "gdb.MemoryError.*: Cannot access memory at address 0x0.*" \ "$test, first test" gdb_test "python inval.fetch_lazy ()" \ - "gdb.MemoryError: Cannot access memory at address 0x0.*" \ + "gdb.MemoryError.*: Cannot access memory at address 0x0.*" \ "$test, second test" } set argc_value [get_integer_valueof "argc" 0] @@ -338,7 +338,7 @@ proc test_value_in_inferior {} { # non-memory value. gdb_py_test_silent_cmd "python str = '\"str\"'" "set up str variable" 1 gdb_test "python print (gdb.parse_and_eval (str).string (length = 10))" \ - "gdb.error: Attempt to take address of value not located in memory.\r\nError while executing Python code." + "gdb.error.*: Attempt to take address of value not located in memory.\r\nError occurred in Python.*" gdb_test "python print (gdb.parse_and_eval ('shadowed'))" \ 97 "shadowed local value" @@ -385,7 +385,7 @@ proc test_objfiles {} { gdb_test "python print (gdb.objfiles()\[0\].pretty_printers)" "\\\[\\\]" gdb_test "python gdb.objfiles()\[0\].pretty_printers = 0" \ - "pretty_printers attribute must be a list.*Error while executing Python code." + "pretty_printers attribute must be a list.*Error occurred in Python.*" } proc test_value_after_death {} { @@ -463,7 +463,7 @@ proc test_subscript_regression {exefile lang} { # Try to access an int with a subscript. This should fail. gdb_test "python print (intv)" "1" "baseline print of an int Python value" - gdb_test "python print (intv\[0\])" "gdb.error: Cannot subscript requested type.*" \ + gdb_test "python print (intv\[0\])" "gdb.error.*: Cannot subscript requested type.*" \ "Attempt to access an integer with a subscript" # Try to access a string with a subscript. This should pass. @@ -478,7 +478,7 @@ proc test_subscript_regression {exefile lang} { # Try to access a single dimension array with a subscript to the # result. This should fail. - gdb_test "python print (pointer\[intv\]\[0\])" "gdb.error: Cannot subscript requested type.*" \ + gdb_test "python print (pointer\[intv\]\[0\])" "gdb.error.*: Cannot subscript requested type.*" \ "Attempt to access a single dimension array with a two subscripts" # Lastly, test subscript access to an array with multiple @@ -568,7 +568,7 @@ proc test_value_from_buffer {} { gdb_test_no_output \ { python compare_value_bytes_to_mem(v, (int(addr) + (2 * size_a0)), size_a0) } gdb_test "python v=gdb.Value(b\[2*size_a0+1:\],tp); print(v)" \ - "ValueError: Size of type is larger than that of buffer object\..*" \ + "ValueError.*: Size of type is larger than that of buffer object\..*" \ "attempt to convert smaller buffer than size of type" gdb_py_test_silent_cmd "python atp=tp.array(2) ; print(atp)" \ "make array type" 0 @@ -580,17 +580,17 @@ proc test_value_from_buffer {} { gdb_test "python print(va\[0\])" "1" "print first array element" gdb_test "python print(va\[1\])" "2" "print second array element" gdb_test "python print(va\[2\])" "3" "print third array element" - gdb_test "python print(va\[3\])" "gdb\.error: no such vector element.*" \ + gdb_test "python print(va\[3\])" "gdb\.error.*: no such vector element.*" \ "print out of bounds array element" gdb_py_test_silent_cmd "python atpbig=tp.array(3)" "make bigger array type" 0 gdb_test "python vabig=gdb.Value(b,atpbig)" \ - "ValueError: Size of type is larger than that of buffer object\..*" \ + "ValueError.*: Size of type is larger than that of buffer object\..*" \ "attempt to construct large value with small buffer" gdb_test "python v=gdb.Value(2048,tp)" \ - "TypeError: Object must support the python buffer protocol\..*" \ + "TypeError.*: Object must support the python buffer protocol\..*" \ "attempt to construct value from buffer with non-buffer object" gdb_test "python v=gdb.Value(b,'int'); print(v)" \ - "TypeError: type argument must be a gdb\.Type\..*" \ + "TypeError.*: type argument must be a gdb\.Type\..*" \ "attempt to construct value with string as type" } @@ -616,7 +616,7 @@ proc test_add_to_history {} { # Try adding something that can't be converted to a gdb.Value, # this should give an error. gdb_test "python idx = gdb.add_history(gdb.GdbError(\"an error\"))" \ - "TypeError: Could not convert Python object: .*" + "TypeError.*: Could not convert Python object: .*" } # Check we can create sub-classes of gdb.Value. @@ -658,8 +658,8 @@ proc_with_prefix test_value_bytes { } { # Test accessing the bytes of an optimised out value. gdb_test "python print(gdb.Value(gdb.Value(5).type.optimized_out()).bytes)" \ [multi_line \ - "gdb\\.error: value has been optimized out" \ - "Error while executing Python code\\."] + "gdb\\.error.*: value has been optimized out" \ + "Error occurred in Python.*"] # A Python helper function. Fetch VAR_NAME from the inferior as a # gdb.Value. Read the bytes of the value based on its address, and @@ -724,11 +724,11 @@ proc_with_prefix test_value_bytes { } { gdb_test_no_output "python bytes_as_int.append(0)" gdb_test_no_output "python too_many_bytes = bytes(bytes_as_int)" gdb_test "python i_value.bytes = too_many_bytes" \ - "ValueError: Size of type is not equal to that of buffer object\\..*" + "ValueError.*: Size of type is not equal to that of buffer object\\..*" gdb_test_no_output "python bytes_as_int = bytes_as_int\[0:-2\]" gdb_test_no_output "python too_few_bytes = bytes(bytes_as_int)" gdb_test "python i_value.bytes = too_few_bytes" \ - "ValueError: Size of type is not equal to that of buffer object\\..*" + "ValueError.*: Size of type is not equal to that of buffer object\\..*" # Check we get an exception writing to a not_lval. gdb_test_no_output "python i_value = gdb.Value(9)" \ diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp index c0d398c29b3..175a6de7ca0 100644 --- a/gdb/testsuite/gdb.python/python.exp +++ b/gdb/testsuite/gdb.python/python.exp @@ -132,7 +132,7 @@ gdb_test_multiline "post event insertion" \ "end" "" gdb_test "python print (someVal)" "1" "test post event execution" -gdb_test "python gdb.post_event(str(1))" "RuntimeError: Posted event is not callable.*" \ +gdb_test "python gdb.post_event(str(1))" "RuntimeError.*: Posted event is not callable.*" \ "test non callable class" send_gdb "python gdb.post_event(lambda: invalid())\n" @@ -162,7 +162,7 @@ gdb_test_multiple "python print (\"\\n\" * $lines)" $test { pass $test } } -gdb_test "q" "Quit.*Error while executing Python.*" "verify pagination beforehand: q" +gdb_test "q" "Quit.*" "verify pagination beforehand: q" gdb_test "python if gdb.execute('python print (\"\\\\n\" * $lines)', to_string=True) == \"\\n\" * [expr $lines + 1]: print (\"yes\")" "yes" "gdb.execute does not page" @@ -178,7 +178,7 @@ gdb_test_multiple "python print (\"\\n\" * $lines)" $test { pass $test } } -gdb_test "q" "Quit.*Error while executing Python.*" "verify pagination afterwards: q" +gdb_test "q" "Quit.*" "verify pagination afterwards: q" gdb_test_no_output "set height 0" @@ -223,7 +223,7 @@ runto $lineno # Test gdb.decode_line. gdb_test "python gdb.decode_line(\"main.c:43\")" \ - "gdb.error: No source file named main.c.*" "test decode_line no source named main" + "gdb.error.*: No source file named main.c.*" "test decode_line no source named main" with_test_prefix "test decode_line current location" { gdb_py_test_silent_cmd "python symtab = gdb.decode_line()" "decode current line" 1 @@ -253,7 +253,7 @@ with_test_prefix "test decode_line" { gdb_test "python print (symtab\[1\]\[0\].line)" "26" "python.c:26 line number" gdb_test "python gdb.decode_line(\"randomfunc\")" \ - "gdb.error: Function \"randomfunc\" not defined.*" "randomfunc" + "gdb.error.*: Function \"randomfunc\" not defined.*" "randomfunc" gdb_py_test_silent_cmd "python symtab = gdb.decode_line(\"func1\")" "func1()" 1 gdb_test "python print (len(symtab))" "2" "func1 length 2" gdb_test "python print (len(symtab\[1\]))" "1" "func1 length 1" diff --git a/gdb/testsuite/gdb.python/tui-window-names.exp b/gdb/testsuite/gdb.python/tui-window-names.exp index 03cd86bae7e..8236fc9a1a3 100644 --- a/gdb/testsuite/gdb.python/tui-window-names.exp +++ b/gdb/testsuite/gdb.python/tui-window-names.exp @@ -39,21 +39,21 @@ foreach c {$ * \{ \} ( ) @ #} { set re [string_to_regexp "$c"] gdb_test "python gdb.register_window_type('te${c}st', failwin)" \ [multi_line \ - "gdb.error: invalid character '${re}' in window name" \ - "Error while executing Python code\\." ] + "gdb.error.*: invalid character '${re}' in window name" \ + "Error occurred in Python.*" ] gdb_test "python gdb.register_window_type('${c}test', failwin)" \ [multi_line \ - "gdb.error: invalid character '${re}' in window name" \ - "Error while executing Python code\\." ] + "gdb.error.*: invalid character '${re}' in window name" \ + "Error occurred in Python.*" ] } # Check that whitespace within a window name is rejected. foreach c [list " " "\\t" "\\n" "\\r"] { gdb_test "python gdb.register_window_type('te${c}st', failwin)" \ [multi_line \ - "gdb.error: invalid whitespace character in window name" \ - "Error while executing Python code\\." ] + "gdb.error.*: invalid whitespace character in window name" \ + "Error occurred in Python.*" ] } # Check some of the characters which are allowed within a window name, @@ -62,8 +62,8 @@ foreach c {1 _ - .} { set re [string_to_regexp "$c"] gdb_test "python gdb.register_window_type('${c}test', failwin)" \ [multi_line \ - "gdb.error: window name must start with a letter, not '${re}'" \ - "Error while executing Python code\\." ] + "gdb.error.*: window name must start with a letter, not '${re}'" \ + "Error occurred in Python.*" ] } # Check different capitalisations. diff --git a/gdb/testsuite/gdb.python/tui-window.exp b/gdb/testsuite/gdb.python/tui-window.exp index ad91fff79cc..e7ff1621fe8 100644 --- a/gdb/testsuite/gdb.python/tui-window.exp +++ b/gdb/testsuite/gdb.python/tui-window.exp @@ -50,7 +50,7 @@ Term::check_contents "Window display" "Test: 0" Term::command "python delete_window_title ()" Term::check_contents "error message after trying to delete title" \ - "TypeError: Cannot delete \"title\" attribute\\." + "TypeError.*: Cannot delete \"title\" attribute\\." Term::check_contents "title is unchanged" \ "This Is The Title" From patchwork Fri Feb 16 18:37:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 85897 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 148F63857B98 for ; Fri, 16 Feb 2024 18:38:52 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by sourceware.org (Postfix) with ESMTPS id CE25B3857B8B for ; Fri, 16 Feb 2024 18:37:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CE25B3857B8B Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CE25B3857B8B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d2a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708108676; cv=none; b=JQzBCdAflqq5W1SNfg3kDBHdLoKtYVB4DrqXR0bTijcsqmglZH+GgJuOctpJRrHC8CIvUeWpIvcbNJy+mSmu8kcd71Sxba0WxOPJmavendZzx5heVTyjlJPezDvFSR9olCfAuJCftlYGmeU5Jy/fqYe40I/LEBcuRgns6Nosn2k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708108676; c=relaxed/simple; bh=PE6FMN8JF9htJOCoUHh2T+NubYNg/rPhxFz6gUlzQxQ=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=RrSVqDMs2YHIud/W3C8JhrMTTgk0TZLl6ApmRMBI6KjQD2CnCHQ40tmPYpvSkoFoijdXc69UMW/TVjb1KwE5Nf8dsrBfsh/vj9Ftkv+R1qpTd5wXrCC+MwXpINO/kEsAy4/IRgfvrJhXzQxpJGSxeg8I3aE0RJ5IqcRk8M2lFHw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd2a.google.com with SMTP id ca18e2360f4ac-7c488a5af5eso62998739f.1 for ; Fri, 16 Feb 2024 10:37:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1708108674; x=1708713474; darn=sourceware.org; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=D1GEiwcLLgEWu4FpIbbXq8Rl6VCVctLEIeK5OYhqEGk=; b=G52i3FlMAXsr8fkB5jTKY8r5U/prJAawALwM1uuuiSwCSqOCF2WrBd9zVBhMt+RnCy 25YnwAhP1n9g0hjti7TasePFYhnQNKxuuRhWaBMxcYMzg0dDMdd5JRHgHCQIOqDxJu8S K1yQjIqGp5upUhIQhIfB2IeAr+y1V1IDMuPcJxjWYVtw46HPQZElp9T+/L73jSmEHDsh VB/xny3+bWphGY0UvC+zVtQ4NtalWh8PLctB5gxUEZzlHVb7vWaDa6symUPQGp+BZt4r JmRevwQxP19soMBtV02xYJpuhjfeETlWzLvpka+ux17pAcfjClTNXWEE38E2jbhPRGCi G8Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708108674; x=1708713474; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D1GEiwcLLgEWu4FpIbbXq8Rl6VCVctLEIeK5OYhqEGk=; b=qNNF/l5r8j/nrMXjlEt7rkUhMa7gJkjFLhUyjEBJfnhwTeDS3DptFSbzaiLOR4jVhm SS6tlDHiDE+ol2MklJew5ueCeHUk+E/7dtbCxwlN8gR/tYPv/qicVDAegXNIB6vv3qQT ixwhKiS78n1vrk8AGMAk9Z731529f9vf33C5GOKN6KYug73djm8xev+CpsqJTyMqx/ky lRuwo8CIyfE//F//JmNOL63X+Y5c49M+Fspn0ixLK2Ojbjb4g06TYpX8GUhtOPctxkB/ 5UrLQDx22+eKnqGWFkIqffE8/91p7jY5uucHqlxk0g8oo4Nka1ktUQSreDcgiX+J+sqZ d9NQ== X-Gm-Message-State: AOJu0YwYd4NCBDEAc3u3/ONOmM9gb2h/jBuz4FqsBUdFkJ3tygMaZY8F qzjWAvaN4FxOdqhm1gvbUj2G8vCEA/M6qZITdn8GUtovdMCKJx0sKLvNuER35Xl69zL65kDHI9o = X-Google-Smtp-Source: AGHT+IHCFQLQtyKfeO79BIQxN/IAQrGlJrj6qNVwQMcz9EGa+vaLF7x5psZHEz18iiL04FhZ/tr2GQ== X-Received: by 2002:a6b:7112:0:b0:7c0:135e:d754 with SMTP id q18-20020a6b7112000000b007c0135ed754mr7374738iog.7.1708108674054; Fri, 16 Feb 2024 10:37:54 -0800 (PST) Received: from localhost.localdomain (71-211-170-195.hlrn.qwest.net. [71.211.170.195]) by smtp.gmail.com with ESMTPSA id g20-20020a0566380bd400b00473eb9f9afcsm104724jad.61.2024.02.16.10.37.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 10:37:53 -0800 (PST) From: Tom Tromey Date: Fri, 16 Feb 2024 11:37:53 -0700 Subject: [PATCH 5/5] Use the .py file in gdb.dap/pause.exp MIME-Version: 1.0 Message-Id: <20240216-py-simple-exc-v1-5-c275bcfb5e4a@adacore.com> References: <20240216-py-simple-exc-v1-0-c275bcfb5e4a@adacore.com> In-Reply-To: <20240216-py-simple-exc-v1-0-c275bcfb5e4a@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Tom de Vries pointed out that the gdb.dap/pause.exp test writes a Python file but then does not use it. This patch corrects the oversight. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31354 --- gdb/testsuite/gdb.dap/pause.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.dap/pause.exp b/gdb/testsuite/gdb.dap/pause.exp index 4d13dadd3ad..9038d0f037f 100644 --- a/gdb/testsuite/gdb.dap/pause.exp +++ b/gdb/testsuite/gdb.dap/pause.exp @@ -134,7 +134,7 @@ dap_read_response cancel $cancel_id # does not continue the inferior) can be canceled. # -write_file py "while True:\n pass" +set gdbfile [write_file py "while True:\n pass"] set cont_id [dap_send_request evaluate \ [format {o expression [s "source %s"] context [s repl]} \ $gdbfile]]