public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 7/8] gdb: remove unnecessary nullptr check in free_objfile observers
Date: Tue,  3 Oct 2023 22:20:22 -0400	[thread overview]
Message-ID: <20231004022305.298534-8-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <20231004022305.298534-1-simon.marchi@polymtl.ca>

From: Simon Marchi <simon.marchi@efficios.com>

The free_objfile observable is never called with a nullptr objfile.

Change-Id: I1e990edeb45bc38009ccb129c623911097ab65fe
---
 gdb/breakpoint.c | 3 ---
 gdb/printcmd.c   | 7 +------
 gdb/symfile.c    | 3 +--
 3 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index f378edf865ea..db7d2e6a8e53 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -8065,9 +8065,6 @@ disable_breakpoints_in_unloaded_shlib (program_space *pspace, so_list *solib)
 static void
 disable_breakpoints_in_freed_objfile (struct objfile *objfile)
 {
-  if (objfile == NULL)
-    return;
-
   /* OBJF_SHARED|OBJF_USERLOADED objfiles are dynamic modules manually
      managed by the user with add-symbol-file/remove-symbol-file.
      Similarly to how breakpoints in shared libraries are handled in
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 7e5f062caec3..d29a57f89b55 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -2355,12 +2355,7 @@ disable_display_command (const char *args, int from_tty)
 static void
 clear_dangling_display_expressions (struct objfile *objfile)
 {
-  struct program_space *pspace;
-
-  /* With no symbol file we cannot have a block or expression from it.  */
-  if (objfile == NULL)
-    return;
-  pspace = objfile->pspace;
+  program_space *pspace = objfile->pspace;
   if (objfile->separate_debug_objfile_backlink)
     {
       objfile = objfile->separate_debug_objfile_backlink;
diff --git a/gdb/symfile.c b/gdb/symfile.c
index d8b67d094ab2..c2779681cd21 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -3736,8 +3736,7 @@ static void
 symfile_free_objfile (struct objfile *objfile)
 {
   /* Remove the target sections owned by this objfile.  */
-  if (objfile != NULL)
-    current_program_space->remove_target_sections ((void *) objfile);
+  current_program_space->remove_target_sections (objfile);
 }
 
 /* Wrapper around the quick_symbol_functions expand_symtabs_matching "method".
-- 
2.42.0


  parent reply	other threads:[~2023-10-04  2:30 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-04  2:20 [PATCH 0/8] Split new_objfile observable Simon Marchi
2023-10-04  2:20 ` [PATCH 1/8] gdb: add program_space parameter to ada_clear_symbol_cache Simon Marchi
2023-10-04  2:20 ` [PATCH 2/8] gdb: add program_space parameters to some functions in symtab.c Simon Marchi
2023-10-04  2:20 ` [PATCH 3/8] gdb: add program_space parameter to emit_clear_objfiles_event Simon Marchi
2023-10-04  2:20 ` [PATCH 4/8] gdb: use objfile->pspace in auto-load.c Simon Marchi
2023-10-04  2:20 ` [PATCH 5/8] gdb: add program_space parameters to some auto-load functions Simon Marchi
2023-10-04  2:20 ` [PATCH 6/8] gdb: add all_objfiles_removed observer Simon Marchi
2023-10-05 16:35   ` Tom Tromey
2023-10-05 17:13     ` Simon Marchi
2023-10-04  2:20 ` Simon Marchi [this message]
2023-10-04  2:20 ` [PATCH 8/8] gdb: use objfile->pspace in free_objfile observers Simon Marchi
2023-10-05 16:36 ` [PATCH 0/8] Split new_objfile observable Tom Tromey
2023-10-05 17:23   ` Simon Marchi

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=20231004022305.298534-8-simon.marchi@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.com \
    /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).