public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
To: Andrew Burgess <aburgess@redhat.com>
Cc: pedro@palves.net, gdb-patches@sourceware.org
Subject: Re: [PATCH 2/2] gdb: MI stopped events when unwindonsignal is on
Date: Thu, 10 Aug 2023 12:06:30 -0300	[thread overview]
Message-ID: <87v8dnq6mh.fsf@linaro.org> (raw)
In-Reply-To: <dd2debeecb1522b6b15c51bcaa367316228709dd.1691505844.git.aburgess@redhat.com>


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 <gdb-patches@sourceware.org> 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 <http://www.gnu.org/licenses/>.
> +
> +# 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

  reply	other threads:[~2023-08-10 15:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-08 14:45 [PATCH 0/2] Stop notifications " Andrew Burgess
2023-08-08 14:45 ` [PATCH 1/2] gdb/testsuite: add mi_info_frame helper proc (and use it) Andrew Burgess
2023-08-08 14:45 ` [PATCH 2/2] gdb: MI stopped events when unwindonsignal is on Andrew Burgess
2023-08-10 15:06   ` Thiago Jung Bauermann [this message]
2023-08-14 14:50     ` Andrew Burgess
2023-08-15  0:32       ` Thiago Jung Bauermann
2023-08-16 14:28         ` Andrew Burgess
2023-08-18 21:56           ` Thiago Jung Bauermann
2023-08-23  9:33             ` Andrew Burgess
2023-08-29 16:37   ` Simon Marchi
2023-09-08  8:54     ` Andrew Burgess
2023-09-08 10:03     ` Andrew Burgess

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87v8dnq6mh.fsf@linaro.org \
    --to=thiago.bauermann@linaro.org \
    --cc=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@palves.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).