public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH] Check for listeners in emit_exiting_event
Date: Fri,  3 Jun 2022 10:46:19 -0600	[thread overview]
Message-ID: <20220603164619.1861019-1-tromey@adacore.com> (raw)

I noticed that emit_exiting_event does not check whether there are any
listeners before creating the event object.  All other event emitters
do this, so this patch updates this one as well.
---
 gdb/python/python.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gdb/python/python.c b/gdb/python/python.c
index 9bef2252e88..844e1165de0 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -1936,6 +1936,9 @@ init__gdb_module (void)
 static int
 emit_exiting_event (int exit_code)
 {
+  if (evregpy_no_listeners_p (gdb_py_events.gdb_exiting))
+    return 0;
+
   gdbpy_ref<> event_obj = create_event_object (&gdb_exiting_event_object_type);
   if (event_obj == nullptr)
     return -1;
-- 
2.34.1


             reply	other threads:[~2022-06-03 16:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-03 16:46 Tom Tromey [this message]
2022-06-15 19:51 ` Tom Tromey

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=20220603164619.1861019-1-tromey@adacore.com \
    --to=tromey@adacore.com \
    --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).