From: Ronald Hecht <ronald.hecht@gmx.de>
To: gdb-patches@sourceware.org
Subject: Re: [PP?] [PATCH] gdb: z80: Guard against missing symtab in skip_prologue
Date: Thu, 4 Jun 2026 08:58:06 +0200 [thread overview]
Message-ID: <0b20f5db-d812-496d-a2b9-7732f6305646@gmx.de> (raw)
In-Reply-To: <f761683c-9fa3-4e2c-9475-64a08cca932e@simark.ca>
[-- Attachment #1: Type: text/plain, Size: 1774 bytes --]
Hi Simon,
yes, that's fine with me. Thanks for cleaning it up and pushing it.
For reference, I attached the adjusted patch with the compunit nullptr
check removed, matching your suggestion.
Best,
Ronald
On 6/3/26 17:32, Simon Marchi wrote:
> On 6/3/26 8:11 AM, Ronald Hecht wrote:
>> |Hi, this is the patch from PR tdep/34198. It fixes an internal
>> segmentation fault in z80_skip_prologue when setting "break main" on
>> some Z80 binaries. "break *main" works, which points at the
>> prologue/SAL path. Regression-tested manually with the reproducer from
>> the PR. Thanks, Ronald
>> https://sourceware.org/bugzilla/show_bug.cgi?id=34198 |
>> diff --git a/gdb/z80-tdep.c b/gdb/z80-tdep.c
>> index f7e207d02ec3..f2e9b09e3b91 100644
>> --- a/gdb/z80-tdep.c
>> +++ b/gdb/z80-tdep.c
>> @@ -495,12 +495,17 @@ z80_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
>> if (prologue_end != 0)
>> {
>> struct symtab_and_line prologue_sal = find_sal_for_pc (func_addr, 0);
>> - struct compunit_symtab *compunit = prologue_sal.symtab->compunit ();
>> - const char *debug_format = compunit->debugformat ();
>> -
>> - if (debug_format != NULL &&
>> - !strncasecmp ("dwarf", debug_format, strlen("dwarf")))
>> - return std::max (pc, prologue_end);
>> + if (prologue_sal.symtab != nullptr)
>> + {
>> + struct compunit_symtab *compunit = prologue_sal.symtab->compunit ();
>> + if (compunit != nullptr)
> symtab->compunit() can't return nullptr, so I wouldn't add this check
> (that method should be modified to return a reference, to make it
> clear).
>
> The patch looks good otherwise. Would you be ok with me pushing your
> patch with that change?
>
> Simon
[-- Attachment #2: z80-skip-prologue-nullcheck-v2.patch --]
[-- Type: text/x-patch, Size: 974 bytes --]
diff --git a/gdb/z80-tdep.c b/gdb/z80-tdep.c
index f7e207d0..0c6e1a2a 100644
--- a/gdb/z80-tdep.c
+++ b/gdb/z80-tdep.c
@@ -495,12 +495,15 @@ z80_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
if (prologue_end != 0)
{
struct symtab_and_line prologue_sal = find_sal_for_pc (func_addr, 0);
- struct compunit_symtab *compunit = prologue_sal.symtab->compunit ();
- const char *debug_format = compunit->debugformat ();
-
- if (debug_format != NULL &&
- !strncasecmp ("dwarf", debug_format, strlen("dwarf")))
- return std::max (pc, prologue_end);
+ if (prologue_sal.symtab != nullptr)
+ {
+ struct compunit_symtab *compunit = prologue_sal.symtab->compunit ();
+ const char *debug_format = compunit->debugformat ();
+
+ if (debug_format != nullptr
+ && !strncasecmp ("dwarf", debug_format, strlen ("dwarf")))
+ return std::max (pc, prologue_end);
+ }
}
return pc;
next prev parent reply other threads:[~2026-06-04 7:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-03 12:11 Ronald Hecht
2026-06-03 15:32 ` [PP?] " Simon Marchi
2026-06-04 6:58 ` Ronald Hecht [this message]
2026-06-04 19:49 ` 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=0b20f5db-d812-496d-a2b9-7732f6305646@gmx.de \
--to=ronald.hecht@gmx.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