From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/2] [gdb] Fix rethrow exception slicing in pretty_print_insn
Date: Mon, 24 Oct 2022 10:49:12 +0200 [thread overview]
Message-ID: <20221024084913.19429-2-tdevries@suse.de> (raw)
In-Reply-To: <20221024084913.19429-1-tdevries@suse.de>
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.
[1] https://en.cppreference.com/w/cpp/language/throw
Tested on x86_64-linux.
---
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)
--
2.35.3
next prev parent reply other threads:[~2022-10-24 8:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-24 8:49 [PATCH 0/2] [gdb] Fix rethrow exception slicing Tom de Vries
2022-10-24 8:49 ` Tom de Vries [this message]
2022-10-24 8:49 ` [PATCH 2/2] [gdb] Fix rethrow exception slicing in insert_bp_location Tom de Vries
2022-10-24 16:36 ` Pedro Alves
2022-10-24 16:43 ` Tom de Vries
2022-10-24 16:48 ` Simon Marchi
2022-10-25 7:08 ` Tom de Vries
2022-10-24 16:51 ` Pedro Alves
2022-10-25 7:14 ` Tom de Vries
2022-10-25 9:26 ` Pedro Alves
2022-10-24 11:20 ` [PATCH 0/2] [gdb] Fix rethrow exception slicing 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=20221024084913.19429-2-tdevries@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@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).