From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [RFC 1/5] [gdb] Catch gdb_exception_quit in munmap_list::~munmap_list
Date: Tue, 25 Oct 2022 13:19:41 +0200 [thread overview]
Message-ID: <20221025111945.23886-2-tdevries@suse.de> (raw)
In-Reply-To: <20221025111945.23886-1-tdevries@suse.de>
I tried out adding this exception slicing detection code in
munmap_list::~munmap_list () in gdb/compile/compile-object-load.c:
...
try
{
...
}
catch (const gdb_exception_error &ex)
{
/* There's not much the user can do, so just ignore
this. */
}
+ catch (const gdb_exception_quit &ex)
+ {
+ throw;
+ }
+ catch (const gdb_exception &ex)
+ {
+ gdb_assert (0);
+ }
...
and ran into:
...
gdb/compile/compile-object-load.c: In destructor ‘munmap_list::~munmap_list()’:
gdb/compile/compile-object-load.c:64:4: error: \
throw will always call terminate() [-Werror=terminate]
throw;
^~~~~
gdb/compile/compile-object-load.c:64:4: note: \
in C++11 destructors default to noexcept
...
This raises the question of how a gdb_exception_quit should be handled in the
destructor.
Currently it's handled implicitly, and will result in std::terminate, which in
absense of a std::set_terminate should call abort, after printing the type
of the current exception, in other words gdb_exception_quit.
We have a couple of choices to handle this explicitly:
- std::terminate (no change in behaviour),
- gdb_assert (false) (also calls abort, but with more info), or
- ignore (as we do for gdb_exception_error)
It seems to me that a gdb_exception_quit should not cause an abort, so handle
explicitly by ignoring:
...
- catch (const gdb_exception_error &ex)
+ catch (const gdb_exception &ex)
...
Tested on x86_64-linux (though I don't have a setup with libcc1).
---
gdb/compile/compile-object-load.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c
index 4c94ec53899..ca58775880b 100644
--- a/gdb/compile/compile-object-load.c
+++ b/gdb/compile/compile-object-load.c
@@ -54,7 +54,7 @@ munmap_list::~munmap_list ()
{
gdbarch_infcall_munmap (target_gdbarch (), item.addr, item.size);
}
- catch (const gdb_exception_error &ex)
+ catch (const gdb_exception &ex)
{
/* There's not much the user can do, so just ignore
this. */
--
2.35.3
next prev parent reply other threads:[~2022-10-25 11:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-25 11:19 [RFC 0/5] [gdb] Catch rethrow exception slicing Tom de Vries
2022-10-25 11:19 ` Tom de Vries [this message]
2022-10-25 11:19 ` [RFC 2/5] [gdbsupport] Add CATCH_ERROR and CATCH_ERROR_QUIT Tom de Vries
2022-10-25 11:19 ` [RFC 3/5] [gdb/contrib] Add refactor.py Tom de Vries
2022-10-25 11:19 ` [RFC 4/5] [gdb/contrib] Add refactor_gdb_exception.py Tom de Vries
2022-10-25 11:19 ` [RFC 5/5] [gdb] Do refactor_gdb_exception refactoring Tom de Vries
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=20221025111945.23886-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).