Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: simon.marchi@polymtl.ca
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: [PATCH 2/5] gdb/gcore: check return values of some find_memory_region_ftype calls
Date: Tue, 10 Mar 2026 13:30:33 -0400	[thread overview]
Message-ID: <20260310173104.676640-2-simon.marchi@polymtl.ca> (raw)
In-Reply-To: <20260310173104.676640-1-simon.marchi@polymtl.ca>

From: Simon Marchi <simon.marchi@polymtl.ca>

This fixes some spots that didn't check the return value of a
find_memory_region_ftype callback.

Change-Id: Ic57933ce76709ca16c93bc66c21da97afb3163a2
---
 gdb/gcore.c | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/gdb/gcore.c b/gdb/gcore.c
index 7c6d5f8667f7..2bf300c0d29f 100644
--- a/gdb/gcore.c
+++ b/gdb/gcore.c
@@ -558,25 +558,27 @@ objfile_find_memory_regions (struct target_ops *self,
       }
 
   /* Make a stack segment.  */
-  if (derive_stack_segment (&temp_bottom, &temp_top))
-    (*func) (temp_bottom, temp_top - temp_bottom,
-	     true, /* Stack section will be readable.  */
-	     true, /* Stack section will be writable.  */
-	     false, /* Stack section will not be executable.  */
-	     true, /* Stack section will be modified.  */
-	     false, /* No memory tags in the object file.  */
-	     obfd);
+  if (derive_stack_segment (&temp_bottom, &temp_top)
+      && !func (temp_bottom, temp_top - temp_bottom,
+		true,  /* Stack section will be readable.  */
+		true,  /* Stack section will be writable.  */
+		false, /* Stack section will not be executable.  */
+		true,  /* Stack section will be modified.  */
+		false, /* No memory tags in the object file.  */
+		obfd))
+    return false;
 
   /* Make a heap segment.  */
   if (derive_heap_segment (current_program_space->exec_bfd (), &temp_bottom,
-			   &temp_top))
-    (*func) (temp_bottom, temp_top - temp_bottom,
-	     true, /* Heap section will be readable.  */
-	     true, /* Heap section will be writable.  */
-	     false, /* Heap section will not be executable.  */
-	     true, /* Heap section will be modified.  */
-	     false, /* No memory tags in the object file.  */
-	     obfd);
+			   &temp_top)
+      && !func (temp_bottom, temp_top - temp_bottom,
+		true,  /* Heap section will be readable.  */
+		true,  /* Heap section will be writable.  */
+		false, /* Heap section will not be executable.  */
+		true,  /* Heap section will be modified.  */
+		false, /* No memory tags in the object file.  */
+		obfd))
+    return false;
 
   return true;
 }
-- 
2.53.0


  reply	other threads:[~2026-03-10 17:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-10 17:30 [PATCH 1/5] gdb/linux-tdep: check return value of linux_find_memory_region_ftype callback simon.marchi
2026-03-10 17:30 ` simon.marchi [this message]
2026-03-13 18:21   ` [PATCH 2/5] gdb/gcore: check return values of some find_memory_region_ftype calls Tom Tromey
2026-03-10 17:30 ` [PATCH 3/5] gdb/linux-tdep: make linux_find_memory_region_ftype a function_view simon.marchi
2026-03-13 18:25   ` Tom Tromey
2026-03-10 17:30 ` [PATCH 4/5] gdb/linux-tdep: remove linux_collect_thread_registers_ftype typedef simon.marchi
2026-03-13 18:25   ` Tom Tromey
2026-03-14 18:43     ` Simon Marchi
2026-03-10 17:30 ` [PATCH 5/5] gdb: make find_memory_region_ftype a function_view simon.marchi
2026-03-13 18:46   ` Tom Tromey
2026-03-14 18:48     ` Simon Marchi
2026-03-14 19:06   ` [PATCH v2] " simon.marchi
2026-03-19 13:57     ` Tom Tromey
2026-03-19 14:08       ` Simon Marchi
2026-03-13 18:21 ` [PATCH 1/5] gdb/linux-tdep: check return value of linux_find_memory_region_ftype callback 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=20260310173104.676640-2-simon.marchi@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --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