From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id 3B57C385454D; Wed, 23 Nov 2022 05:52:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3B57C385454D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669182767; bh=s5j/63OISXmBKQ/piM0XNkh1ZFPAY3C6wDiiB28W9g0=; h=From:To:Subject:Date:From; b=vlqDTEq3RLPW5wz+dNdB87lP6Fye1oZe0Y3jI0EZsmdQnmxkSZ9zJVEoGx0Vo6Hti 7tpWSX5Af9qoSAIFNPsT600vO17nlRvq4WZyVFVXL0Gwg3SO3kGl/4GvfJglqdBOTq XbNyCHovXE79uZsB8ypCYcvcjjCgxBqfnsNmfHFI= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom de Vries To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Fix gdb.cp/gdb2495.exp on powerpc64le X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: 06f0a892a5260d8fe93550ed96364cc76fef971d X-Git-Newrev: 829b6b3736d972f5fbacda09c82b31802d3b594c Message-Id: <20221123055247.3B57C385454D@sourceware.org> Date: Wed, 23 Nov 2022 05:52:47 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D829b6b3736d9= 72f5fbacda09c82b31802d3b594c commit 829b6b3736d972f5fbacda09c82b31802d3b594c Author: Tom de Vries Date: Wed Nov 23 06:52:42 2022 +0100 Fix gdb.cp/gdb2495.exp on powerpc64le =20 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 exceptio= n \ without a handler. ... =20 The following happens: - we start an inferior call - an internal breakpoint is set on the global entry point of std::termi= nate - the inferior call uses the local entry point - the breakpoint is not triggered - we run into std::terminate =20 We can fix this by simply adding the missing gdbarch_skip_entrypoint ca= ll 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_entr= ypoint - 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. =20 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 scop= e for this patch. =20 Tested on x86_64-linux, powerpc64le-linux. =20 Co-Authored-By: Ulrich Weigand Tested-by: Carl Love PR tdep/29793 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D29793 Diff: --- gdb/breakpoint.c | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index a161b78a8aa..f0276a963c0 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -3296,6 +3296,8 @@ set_breakpoint_number (int internal, struct breakpoin= t *b) } } =20 +/* 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) @@ -3308,6 +3310,33 @@ create_internal_breakpoint (struct gdbarch *gdbarch, return add_to_breakpoint_chain (std::move (b)); } =20 +/* 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 =3D msym.value_address (); + + address =3D 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 =3D gdbarch_skip_entrypoint (gdbarch, address); + + return create_internal_breakpoint (gdbarch, address, type); +} + static const char *const longjmp_names[] =3D { "longjmp", "_longjmp", "siglongjmp", "_siglongjmp" @@ -3557,8 +3586,6 @@ create_std_terminate_master_breakpoint (void) =20 for (struct program_space *pspace : program_spaces) { - CORE_ADDR addr; - set_current_program_space (pspace); =20 for (objfile *objfile : current_program_space->objfiles ()) @@ -3586,8 +3613,8 @@ create_std_terminate_master_breakpoint (void) bp_objfile_data->terminate_msym =3D m; } =20 - addr =3D bp_objfile_data->terminate_msym.value_address (); - b =3D create_internal_breakpoint (objfile->arch (), addr, + b =3D create_internal_breakpoint (objfile->arch (), + bp_objfile_data->terminate_msym, bp_std_terminate_master); b->locspec =3D new_explicit_location_spec_function (func_name); b->enable_state =3D bp_disabled; @@ -3656,7 +3683,6 @@ create_exception_master_breakpoint_hook (objfile *obj= file) struct breakpoint *b; struct gdbarch *gdbarch; struct breakpoint_objfile_data *bp_objfile_data; - CORE_ADDR addr; =20 bp_objfile_data =3D get_breakpoint_objfile_data (objfile); =20 @@ -3679,10 +3705,8 @@ create_exception_master_breakpoint_hook (objfile *ob= jfile) bp_objfile_data->exception_msym =3D debug_hook; } =20 - addr =3D bp_objfile_data->exception_msym.value_address (); - addr =3D gdbarch_convert_from_func_ptr_addr - (gdbarch, addr, current_inferior ()->top_target ()); - b =3D create_internal_breakpoint (gdbarch, addr, bp_exception_master); + b =3D create_internal_breakpoint (gdbarch, bp_objfile_data->exception_ms= ym, + bp_exception_master); b->locspec =3D new_explicit_location_spec_function (func_name); b->enable_state =3D bp_disabled;