From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) by sourceware.org (Postfix) with ESMTPS id C5DC63857736 for ; Thu, 10 Aug 2023 15:06:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C5DC63857736 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ot1-x331.google.com with SMTP id 46e09a7af769-6bd0425ad4fso920002a34.2 for ; Thu, 10 Aug 2023 08:06:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691679995; x=1692284795; h=mime-version:message-id:date:in-reply-to:subject:cc:to:from :user-agent:references:from:to:cc:subject:date:message-id:reply-to; bh=hh+DbUnb1h1oIL6QVNlXyr3Q6NRH5943scu9m8Vr31A=; b=bP5tA6p0BO5DhYbPLhoZ3Iu4s2Rf5ct2urIWtcf2berPIhbllV0z474dS8tUEqlwc2 I3CqI6PbuZuSlROegSiF3PFWDAxkHcvjT7GJ44rHJa0QuPrLH4V2rXhojcafclivJ4k0 JGxpNfceZ0zDG5RI1//ViXzOOXZh45oGmkikj1KxxA/vl5hu9flLkVK+I/V04pR6mkAI ddoq6E69CGsaIS1n25NEimPJczOWHpE7RzPx6qTShhh5kWeB/6psTrkFNX0UsXNBUElo +D9F5KS4BwY94MvKWy4P6HKKfGoj+74vDuZiN+IVPoxU9Mh9SwKt/Kyt2ajDeFB5w//d y+1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691679995; x=1692284795; h=mime-version:message-id:date:in-reply-to:subject:cc:to:from :user-agent:references:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=hh+DbUnb1h1oIL6QVNlXyr3Q6NRH5943scu9m8Vr31A=; b=LwypkEmlUAH2Mfb+RIg2YTRN3cWQXWOPUNUeyWYpkuYu35N25ZN8rVkuyM5fgF/CwH 7dNXjlEQYrgFYpTEnpzXCCu5fIt92FAJOyvmsO1hiSHHI/pdgOlq844/GbkQ4rkqFRvJ Nn6BM8JY8b4qJ/XJoPZUDBeNmyqk+aOp5YDKSOC+jT5darQGSlu33i+D3+B8ednfoRNe vmKXAUfI9xt6UbTe4xJJGkSOZ8TBGka+ZAdBOhzskj2LFvC74WJSW9bcCk4OZcdATeCW Wv3WgC/o4PUErAvkDng6Iz4HDro/AN1Fm11ZMaRsfjUT4DXXNKnAR0YhwAOCDQNq8q0G AxZA== X-Gm-Message-State: AOJu0Yxjfe/xCYEC749Ri0X6MfQb3zji0wOvdL7WSOa2JwH8iYlpH0ZB sLBKOJz4LaY5/Ke0BYofPNKB4Q== X-Google-Smtp-Source: AGHT+IEv5wE4Y+V3mm0PLZhPjq9QBPLPZkOp+ZBHYehqQ9EdjDgccdww/NVHBE8YNfLoZQu9BK/1SA== X-Received: by 2002:a05:6830:1b6d:b0:6bc:63c9:7946 with SMTP id d13-20020a0568301b6d00b006bc63c97946mr2933520ote.14.1691679994730; Thu, 10 Aug 2023 08:06:34 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8470:87e8:b692:174e:9b36]) by smtp.gmail.com with ESMTPSA id h2-20020a9d6a42000000b006b95392cf09sm710156otn.33.2023.08.10.08.06.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Aug 2023 08:06:33 -0700 (PDT) References: User-agent: mu4e 1.10.5; emacs 28.2 From: Thiago Jung Bauermann To: Andrew Burgess Cc: pedro@palves.net, gdb-patches@sourceware.org Subject: Re: [PATCH 2/2] gdb: MI stopped events when unwindonsignal is on In-reply-to: Date: Thu, 10 Aug 2023 12:06:30 -0300 Message-ID: <87v8dnq6mh.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hello, This is an area I don't know much about, so in my reading of the code I didn't find anything to comment. But we are starting to do precommit testing of GDB patches, and our CI caught a failure in gdb.mi/mi-condbreak-throw.exp on armv8l-unknown-linux-gnueabihf and aarch64-linux-gnu: Andrew Burgess via Gdb-patches writes: > diff --git a/gdb/testsuite/gdb.mi/mi-condbreak-throw.exp b/gdb/testsuite/gdb.mi/mi-condbreak-throw.exp > new file mode 100644 > index 00000000000..25fd15e7602 > --- /dev/null > +++ b/gdb/testsuite/gdb.mi/mi-condbreak-throw.exp > @@ -0,0 +1,116 @@ > +# Copyright (C) 2023 Free Software Foundation, Inc. > + > +# This program is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 3 of the License, or > +# (at your option) any later version. > +# > +# This program is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. If not, see . > + > +# Check that when GDB fails to evaluate the condition of a conditional > +# breakpoint we only get one *stopped notification. In this test case > +# the breakpoint condition fails due to throwing an uncaught C++ > +# excpetion. > + > +require allow_cplus_tests > + > +load_lib mi-support.exp > +set MIFLAGS "-i=mi" > + > +standard_testfile .cc > + > +if [build_executable ${testfile}.exp ${binfile} ${srcfile} {debug c++}] { > + return -1 > +} > + > +# Create a breakpoint with a condition that invokes an inferior > +# function call, that will segfault. Run until GDB hits the > +# breakpoint and check how GDB reports the failed condition check. > +# > +# UNWIND_ON_EXCEPTION is either 'on' or 'off'. This is used to configure > +# GDB's 'set unwind-on-terminating-exception' setting. > + > +proc run_test { unwind_on_exception } { > + > + if {[mi_clean_restart $::binfile]} { > + return > + } > + > + if {[mi_runto_main] == -1} { > + return > + } > + > + mi_gdb_test "-gdb-set unwind-on-terminating-exception ${unwind_on_exception}" {\^done} \ > + "set unwind-on-terminating-exception" > + > + # Create the conditional breakpoint. > + set bp_location [gdb_get_line_number "Set breakpoint here"] > + mi_create_breakpoint "-c \"cond_throw ()\" $::srcfile:$bp_location" \ > + "insert conditional breakpoint" \ > + -func "foo\\(\\)" -file ".*$::srcfile" -line "$bp_location" \ > + -cond "cond_throw \\(\\)" > + > + # Number of the previous breakpoint. > + set bpnum [mi_get_valueof "/d" "\$bpnum" "INVALID" \ > + "get number for breakpoint"] > + > + # The line where we expect the inferior to crash. > + set crash_linenum 0 > + #[gdb_get_line_number "Crash here"] > + > + # Run the inferior and wait for it to stop. > + mi_send_resuming_command "exec-continue" "continue the inferior" > + > + if {$unwind_on_exception} { > + mi_gdb_test "" \ > + [multi_line \ > + "&\"Error in testing condition for breakpoint $bpnum:\\\\n\"" \ > + "&\"The program being debugged entered a std::terminate call, most likely\\\\n\"" \ > + "&\"caused by an unhandled C\\+\\+ exception. GDB blocked this call in order\\\\n\"" \ > + "&\"to prevent the program from being terminated, and has restored the\\\\n\"" \ > + "&\"context to its original state before the call.\\\\n\"" \ > + "&\"To change this behaviour use \\\\\"set unwind-on-terminating-exception off\\\\\"\\.\\\\n\"" \ > + "&\"Evaluation of the expression containing the function \\(cond_throw\\(\\)\\)\\\\n\"" \ > + "&\"will be abandoned.\\\\n\"" \ > + "=breakpoint-modified,bkpt={number=\"$bpnum\",type=\"breakpoint\",\[^\r\n\]+times=\"1\",\[^\r\n\]+}" \ > + "~\"\\\\n\"" \ > + "~\"Breakpoint $bpnum, foo \\(\\) at \[^\r\n\]+/${::srcfile}:${bp_location}\\\\n\"" \ > + "~\"${bp_location}\\\\t\[^\r\n\]+Set breakpoint here\\.\[^\r\n\]+\\\\n\"" \ > + "\\*stopped,reason=\"breakpoint-hit\",disp=\"keep\",bkptno=\"$bpnum\",frame=\\{addr=\"$::hex\",func=\"foo\"\\,args=\\\[\\\],file=\"\[^\r\n\]+\",fullname=\"\[^\r\n\]+\",line=\"$bp_location\",\[^\r\n\]+}\[^\r\n\]+"] \ > + "wait for stop" > + > + mi_info_frame "check the current frame" \ > + -level 0 -func foo -line $bp_location > + } else { > + mi_gdb_test "" \ > + [multi_line \ > + "terminate called after throwing an instance of 'int'" \ > + "~\"\\\\nProgram\"" \ > + "~\" received signal SIGABRT, Aborted\\.\\\\n\"" \ > + "~\"$::hex in \[^\r\n\]+\"" \ > + "\\*stopped,reason=\"signal-received\",signal-name=\"SIGABRT\"\[^\r\n\]+frame=\\{addr=\"$::hex\",\[^\r\n\]+\\}\[^\r\n\]+" \ > + "&\"Error in testing condition for breakpoint $bpnum:\\\\n\"" \ > + "&\"The program being debugged was signaled while in a function called from GDB\\.\\\\n\"" \ > + "&\"GDB remains in the frame where the signal was received\\.\\\\n\"" \ > + "&\"To change this behavior use \\\\\"set unwindonsignal on\\\\\"\\.\\\\n\"" \ > + "&\"Evaluation of the expression containing the function\\\\n\"" \ > + "&\"\\(cond_throw\\(\\)\\) will be abandoned\\.\\\\n\"" \ > + "&\"When the function is done executing, GDB will silently stop\\.\\\\n\"" \ > + "=breakpoint-modified,bkpt={number=\"$bpnum\",type=\"breakpoint\",\[^\r\n\]+times=\"1\",\[^\r\n\]+}"] \ > + "wait for stop" This test fails: Expecting: ^([ ]+)?(terminate called after throwing an instance of 'int' ~"\\nProgram" ~" received signal SIGABRT, Aborted\.\\n" ~"0x[0-9A-Fa-f]+ in [^ ]+" \*stopped,reason="signal-received",signal-name="SIGABRT"[^ ]+frame=\{addr="0x[0-9A-Fa-f]+",[^ ]+\}[^ ]+ &"Error in testing condition for breakpoint 2:\\n" &"The program being debugged was signaled while in a function called from GDB\.\\n" &"GDB remains in the frame where the signal was received\.\\n" &"To change this behavior use \\"set unwindonsignal on\\"\.\\n" &"Evaluation of the expression containing the function\\n" &"\(cond_throw\(\)\) will be abandoned\.\\n" &"When the function is done executing, GDB will silently stop\.\\n" =breakpoint-modified,bkpt={number="2",type="breakpoint",[^ ]+times="1",[^ ]+}[ ]+[(]gdb[)] [ ]*) terminate called after throwing an instance of 'int' ~"\nProgram" ~" received signal SIGABRT, Aborted.\n" ~"__pthread_kill_implementation (threadid=281474842417696, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44\n" &"44\t./nptl/pthread_kill.c: No such file or directory.\n" *stopped,reason="signal-received",signal-name="SIGABRT",signal-meaning="Aborted",frame={addr="0x0000fffff7c5f200",func="__pthread_kill_implementation",args=[{name="threadid",value="281474842417696"},{name="signo",value="6"},{name="signo@entry",value="6"},{name="no_tid",value="0"},{name="no_tid@entry",value="0"}],file="./nptl/pthread_kill.c",fullname="./nptl/./nptl/pthread_kill.c",line="44",arch="aarch64"},thread-id="1",stopped-threads="all",core="78" &"Error in testing condition for breakpoint 2:\n" &"The program being debugged was signaled while in a function called from GDB.\n" &"GDB remains in the frame where the signal was received.\n" &"To change this behavior use \"set unwindonsignal on\".\n" &"Evaluation of the expression containing the function\n" &"(cond_throw()) will be abandoned.\n" &"When the function is done executing, GDB will silently stop.\n" =breakpoint-modified,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x0000aaaaaaaa087c",func="foo()",file="/home/tcwg-build/workspace/tcwg_gnu_5/abe/snapshots/gdb.git~master/gdb/testsuite/gdb.mi/mi-condbreak-throw.cc",fullname="/home/tcwg-build/workspace/tcwg_gnu_5/gdb/gdb/testsuite/gdb.mi/mi-condbreak-throw.cc",line="29",thread-groups=["i1"],cond="cond_throw ()",times="1",original-location="mi-condbreak-throw.cc:29"} (gdb) FAIL: gdb.mi/mi-condbreak-throw.exp: unwind_on_exception=off: wait for stop (unexpected output) It looks like the testcase isn't expecting these lines: ~"__pthread_kill_implementation (threadid=281474842417696, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44\n" &"44\t./nptl/pthread_kill.c: No such file or directory.\n" > + > + # Don't try to check the current frame here, the inferior will > + # be stopped somewhere in the C++ runtime at the point where > + # it is determined that the exception has not been handled. > + } > +} > + > +foreach_with_prefix unwind_on_exception { off } { > + run_test $unwind_on_exception > +} -- Thiago