From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id 801A63858284; Mon, 24 Oct 2022 12:20:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 801A63858284 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666614054; bh=SatPNpiiJ6T1O9hU/8RgXpuGbMXbAE87yj3T7B/R1so=; h=From:To:Subject:Date:From; b=SQxy3yWY2hfa/fNLxS8HxMl4lEOdRgsgFQ57+FEdXtZrAF3K9woRHwIIVUYptnfWW TseANTAWRdEk6wvH90Lqe7F9QRqswHuAs2x2YSXXOUbNVRo4N/xmn0QrZ/BDwgMZXS obCh9X8/FiQCPP37J8rBIoWEfRJIlkecD/0ulbjs= 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] [gdb] Fix rethrow exception slicing in pretty_print_insn X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: 67527cffcd5eb548a5de26d6a2b139a52bffa5a6 X-Git-Newrev: 0a9c805dfd0dd9a284b30ec0563e4dc1ab5b16c4 Message-Id: <20221024122054.801A63858284@sourceware.org> Date: Mon, 24 Oct 2022 12:20:53 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D0a9c805dfd0d= d9a284b30ec0563e4dc1ab5b16c4 commit 0a9c805dfd0dd9a284b30ec0563e4dc1ab5b16c4 Author: Tom de Vries Date: Mon Oct 24 14:20:49 2022 +0200 [gdb] Fix rethrow exception slicing in pretty_print_insn =20 The preferred way of rethrowing an exception is by using throw without expression, because it avoids object slicing of the exception [1]. =20 Fix this in gdb_pretty_print_disassembler::pretty_print_insn. =20 Tested on x86_64-linux. =20 [1] https://en.cppreference.com/w/cpp/language/throw =20 Approved-By: Andrew Burgess Diff: --- gdb/disasm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gdb/disasm.c b/gdb/disasm.c index de44aac3263..60f95c398a9 100644 --- a/gdb/disasm.c +++ b/gdb/disasm.c @@ -445,7 +445,7 @@ gdb_pretty_print_disassembler::pretty_print_insn (const= struct disasm_insn *insn size =3D m_di.print_insn (pc); gdb_assert (size > 0); } - catch (const gdb_exception &ex) + catch (const gdb_exception &) { /* An exception was thrown while disassembling the instruction. However, the disassembler might still have written something @@ -454,7 +454,7 @@ gdb_pretty_print_disassembler::pretty_print_insn (const= struct disasm_insn *insn object destructor as the write itself might throw an exception if the pager kicks in, and the user selects quit. */ write_out_insn_buffer (); - throw ex; + throw; } =20 if ((flags & (DISASSEMBLY_RAW_INSN | DISASSEMBLY_RAW_BYTES)) !=3D 0)