public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tom de Vries <vries@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] [gdb] Fix rethrow exception slicing in pretty_print_insn
Date: Mon, 24 Oct 2022 12:20:53 +0000 (GMT)	[thread overview]
Message-ID: <20221024122054.801A63858284@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0a9c805dfd0dd9a284b30ec0563e4dc1ab5b16c4

commit 0a9c805dfd0dd9a284b30ec0563e4dc1ab5b16c4
Author: Tom de Vries <tdevries@suse.de>
Date:   Mon Oct 24 14:20:49 2022 +0200

    [gdb] Fix rethrow exception slicing in pretty_print_insn
    
    The preferred way of rethrowing an exception is by using throw without
    expression, because it avoids object slicing of the exception [1].
    
    Fix this in gdb_pretty_print_disassembler::pretty_print_insn.
    
    Tested on x86_64-linux.
    
    [1] https://en.cppreference.com/w/cpp/language/throw
    
    Approved-By: Andrew Burgess <aburgess@redhat.com>

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 = 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;
       }
 
     if ((flags & (DISASSEMBLY_RAW_INSN | DISASSEMBLY_RAW_BYTES)) != 0)

                 reply	other threads:[~2022-10-24 12:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20221024122054.801A63858284@sourceware.org \
    --to=vries@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /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).