diff options
author | Tom Tromey <tom@tromey.com> | 2021-06-27 11:06:04 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2021-07-30 08:42:39 -0600 |
commit | 785e5700ce4bda469e323d1dc7eeae9d86980c79 (patch) | |
tree | a16c1cce4eec5f386703f3587a2c26a020c5a494 /gdbsupport | |
parent | fb6262e8534e0148a4a424e9e5138159af19faf1 (diff) | |
download | gdb-785e5700ce4bda469e323d1dc7eeae9d86980c79.zip gdb-785e5700ce4bda469e323d1dc7eeae9d86980c79.tar.gz gdb-785e5700ce4bda469e323d1dc7eeae9d86980c79.tar.bz2 |
Replace exception_print_same with operator!=
I noticed that exception_print_same is only used in a single spot, and
it seemed to be better as an operator!= method attached to
gdb_exception.
Regression tested on x86-64 Fedora 34.
Diffstat (limited to 'gdbsupport')
-rw-r--r-- | gdbsupport/common-exceptions.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gdbsupport/common-exceptions.h b/gdbsupport/common-exceptions.h index 92f43d2..5933c73 100644 --- a/gdbsupport/common-exceptions.h +++ b/gdbsupport/common-exceptions.h @@ -165,6 +165,23 @@ struct gdb_exception return message->c_str (); } + /* Compare two exceptions. */ + bool operator== (const gdb_exception &other) const + { + const char *msg1 = message == nullptr ? "" : what (); + const char *msg2 = other.message == nullptr ? "" : other.what (); + + return (reason == other.reason + && error == other.error + && strcmp (msg1, msg2) == 0); + } + + /* Compare two exceptions. */ + bool operator!= (const gdb_exception &other) const + { + return !(*this == other); + } + enum return_reason reason; enum errors error; std::shared_ptr<std::string> message; |