From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 98CF73854555 for ; Wed, 23 Nov 2022 05:55:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 98CF73854555 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 9DDE921B90; Wed, 23 Nov 2022 05:55:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1669182951; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f0EKJDdcQOdCo+fOU7d+7jqR9E6lHMg8uT0QLRSrcIw=; b=AuJPs6mk1JtTZ5FNsaDTu0vXPwBDzDBSknFgBBnjRuXZhQEBaqQIC2a0SurILaNMB8VzrQ xpIy6Ajer9WstC+nBdfDRmUNEqv3zRVK6b9FJmiCMpx735rCJOwqQwnCyHL2tEqWN/ffkq Y0I+dEh3LN2za4XuaxWFjUbQeielQoE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1669182951; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f0EKJDdcQOdCo+fOU7d+7jqR9E6lHMg8uT0QLRSrcIw=; b=MwgkHLDBOMtbkOuXMUOHpzbl3CgzM4OqcKYG0On9YL59Imf4SS3RdE288ZhzokF6qdumeg 3/WHLFIzw3o1CGBQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 646D613AE7; Wed, 23 Nov 2022 05:55:51 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id GQwTFue1fWMsLAAAMHmgww (envelope-from ); Wed, 23 Nov 2022 05:55:51 +0000 Message-ID: Date: Wed, 23 Nov 2022 06:55:50 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH] Fix gdb.cp/gdb2495.exp on powerpc64le To: gdb-patches@sourceware.org Cc: Ulrich Weigand , Carl Love References: <20221118164323.10089-1-tdevries@suse.de> Content-Language: en-US From: Tom de Vries In-Reply-To: <20221118164323.10089-1-tdevries@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 11/18/22 17:43, Tom de Vries via Gdb-patches wrote: > From: Tom de Vries > > On powerpc64le-linux I ran into this FAIL: > ... > (gdb) p exceptions.throw_function()^M > terminate called after throwing an instance of 'int'^M > ^M > Program received signal SIGABRT, Aborted.^M > 0x00007ffff7979838 in raise () from /lib64/libc.so.6^M > The program being debugged was signaled while in a function called from GDB.^M > GDB remains in the frame where the signal was received.^M > To change this behavior use "set unwindonsignal on".^M > Evaluation of the expression containing the function^M > (SimpleException::throw_function()) will be abandoned.^M > When the function is done executing, GDB will silently stop.^M > (gdb) FAIL: gdb.cp/gdb2495.exp: call a function that raises an exception \ > without a handler. > ... > > The following happens: > - we start an inferior call > - an internal breakpoint is set on the global entry point of std::terminate > - the inferior call uses the local entry point > - the breakpoint is not triggered > - we run into std::terminate > > We can fix this by simply adding the missing gdbarch_skip_entrypoint call in > create_std_terminate_master_breakpoint, but we try to do this a bit more > generic, by: > - adding a variant of function create_internal_breakpoint which takes a > minimal symbol instead of an address as argument > - in the new function: > - using both gdbarch_convert_from_func_ptr_addr and gdbarch_skip_entrypoint > - documenting why we don't need to use gdbarch_addr_bits_remove > - adding a note about possibly > needing gdbarch_deprecated_function_start_offset. > - using the new function in: > - create_std_terminate_master_breakpoint > - create_exception_master_breakpoint_hook, which currently uses only > gdbarch_convert_from_func_ptr_addr. > > Note: we could use the new function in more locations in breakpoint.c, but > as we're not aware of any related failures, we declare this out of scope for > this patch. > > Tested on x86_64-linux, powerpc64le-linux. > > Co-Authored-By: Ulrich Weigand > PR tdep/29793 > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29793 I've pushed this, with a tested-by tag added. Thanks, - Tom > --- > gdb/breakpoint.c | 42 +++++++++++++++++++++++++++++++++--------- > 1 file changed, 33 insertions(+), 9 deletions(-) > > diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c > index 490708938ec..578d45b15af 100644 > --- a/gdb/breakpoint.c > +++ b/gdb/breakpoint.c > @@ -3283,6 +3283,8 @@ set_breakpoint_number (int internal, struct breakpoint *b) > } > } > > +/* Create a TYPE breakpoint on ADDRESS from an object file with GDBARCH. */ > + > static struct breakpoint * > create_internal_breakpoint (struct gdbarch *gdbarch, > CORE_ADDR address, enum bptype type) > @@ -3295,6 +3297,33 @@ create_internal_breakpoint (struct gdbarch *gdbarch, > return add_to_breakpoint_chain (std::move (b)); > } > > +/* Create a TYPE breakpoint on minimal symbol MSYM from an object file with > + GDBARCH. */ > + > +static struct breakpoint * > +create_internal_breakpoint (struct gdbarch *gdbarch, > + struct bound_minimal_symbol &msym, enum bptype type) > +{ > + CORE_ADDR address; > + > + address = msym.value_address (); > + > + address = gdbarch_convert_from_func_ptr_addr > + (gdbarch, address, current_inferior ()->top_target ()); > + > + /* Note that we're not using gdbarch_addr_bits_remove here, because that's > + related to addresses in $pc. We're getting the address from the > + minimal symbol table. */ > + > + /* Is gdbarch_deprecated_function_start_offset needed here? Or is that dealt > + with elsewhere? Needs testing on vax. */ > + > + if (gdbarch_skip_entrypoint_p (gdbarch)) > + address = gdbarch_skip_entrypoint (gdbarch, address); > + > + return create_internal_breakpoint (gdbarch, address, type); > +} > + > static const char *const longjmp_names[] = > { > "longjmp", "_longjmp", "siglongjmp", "_siglongjmp" > @@ -3544,8 +3573,6 @@ create_std_terminate_master_breakpoint (void) > > for (struct program_space *pspace : program_spaces) > { > - CORE_ADDR addr; > - > set_current_program_space (pspace); > > for (objfile *objfile : current_program_space->objfiles ()) > @@ -3573,8 +3600,8 @@ create_std_terminate_master_breakpoint (void) > bp_objfile_data->terminate_msym = m; > } > > - addr = bp_objfile_data->terminate_msym.value_address (); > - b = create_internal_breakpoint (objfile->arch (), addr, > + b = create_internal_breakpoint (objfile->arch (), > + bp_objfile_data->terminate_msym, > bp_std_terminate_master); > b->locspec = new_explicit_location_spec_function (func_name); > b->enable_state = bp_disabled; > @@ -3643,7 +3670,6 @@ create_exception_master_breakpoint_hook (objfile *objfile) > struct breakpoint *b; > struct gdbarch *gdbarch; > struct breakpoint_objfile_data *bp_objfile_data; > - CORE_ADDR addr; > > bp_objfile_data = get_breakpoint_objfile_data (objfile); > > @@ -3666,10 +3692,8 @@ create_exception_master_breakpoint_hook (objfile *objfile) > bp_objfile_data->exception_msym = debug_hook; > } > > - addr = bp_objfile_data->exception_msym.value_address (); > - addr = gdbarch_convert_from_func_ptr_addr > - (gdbarch, addr, current_inferior ()->top_target ()); > - b = create_internal_breakpoint (gdbarch, addr, bp_exception_master); > + b = create_internal_breakpoint (gdbarch, bp_objfile_data->exception_msym, > + bp_exception_master); > b->locspec = new_explicit_location_spec_function (func_name); > b->enable_state = bp_disabled; > > > base-commit: f9f88aede3bb84efd088a59a5f6bccb3a6bb6516