From: Andrew Burgess <aburgess@redhat.com>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 1/2] gdb: int to bool in struct entry_info
Date: Fri, 17 Apr 2026 16:30:48 +0100 [thread overview]
Message-ID: <87cxzx4n9z.fsf@redhat.com> (raw)
In-Reply-To: <87fr4tty5h.fsf@tromey.com>
Tom Tromey <tom@tromey.com> writes:
>>>>>> "Andrew" == Andrew Burgess <aburgess@redhat.com> writes:
>
> Andrew> Convert 'struct entry_info' to use bool for flag fields. The places
> Andrew> where these flags are set are updated too.
>
> Andrew> There should be no user visible changes after this commit.
>
> Andrew> - /* Set to 1 iff ENTRY_POINT contains a valid value. */
> Andrew> - unsigned entry_point_p : 1;
> Andrew> + /* Set to true iff ENTRY_POINT contains a valid value. */
> Andrew> + bool entry_point_p : 1;
>
> Andrew> - /* Set to 1 iff this object was initialized. */
> Andrew> - unsigned initialized : 1;
> Andrew> + /* Set to true iff this object was initialized. */
> Andrew> + bool initialized : 1;
>
> I think we should only use bit fields where space is at a premium.
> Perhaps when using 'unsigned' here this was done to convey that these
> are 1-bit entities? I am not sure. But anyway I think removing the ":
> 1" would be an improvement, and since you're touching this line anyway
> updating it would be good.
Revised patch below.
Thanks,
Andrew
---
commit db24e933773242df7a23159c03b20bf8b509544c
Author: Andrew Burgess <aburgess@redhat.com>
gdb: int to bool in struct entry_info
Convert 'struct entry_info' to use bool for flag fields. The places
where these flags are set are updated too. I have also removed the
bit width specifier ": 1" from the flag field definitions. There is
one entry_info struct per BFD in GDB, which is not a huge number, so
forcing the bool fields to 1-bit doesn't seen necessary.
There should be no user visible changes after this commit.
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 89ac559ce81..537116e985c 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -115,11 +115,11 @@ struct entry_info
/* The index of the section in which the entry point appears. */
int the_bfd_section_index;
- /* Set to 1 iff ENTRY_POINT contains a valid value. */
- unsigned entry_point_p : 1;
+ /* Set to true iff ENTRY_POINT contains a valid value. */
+ bool entry_point_p;
- /* Set to 1 iff this object was initialized. */
- unsigned initialized : 1;
+ /* Set to true iff this object was initialized. */
+ bool initialized;
};
#define SECT_OFF_DATA(objfile) \
diff --git a/gdb/symfile.c b/gdb/symfile.c
index d0ea9506c63..d583960d430 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -776,7 +776,7 @@ init_entry_point_info (struct objfile *objfile)
if (ei->initialized)
return;
- ei->initialized = 1;
+ ei->initialized = true;
/* Save startup file's range of PC addresses to help blockframe.c
decide where the bottom of the stack is. */
@@ -786,7 +786,7 @@ init_entry_point_info (struct objfile *objfile)
/* Executable file -- record its entry point so we'll recognize
the startup file because it contains the entry point. */
ei->entry_point = bfd_get_start_address (objfile->obfd.get ());
- ei->entry_point_p = 1;
+ ei->entry_point_p = true;
}
else if (bfd_get_file_flags (objfile->obfd.get ()) & DYNAMIC
&& bfd_get_start_address (objfile->obfd.get ()) != 0)
@@ -795,12 +795,12 @@ init_entry_point_info (struct objfile *objfile)
runnable. There's no clear way to indicate this, so just check
for values other than zero. */
ei->entry_point = bfd_get_start_address (objfile->obfd.get ());
- ei->entry_point_p = 1;
+ ei->entry_point_p = true;
}
else
{
/* Examination of non-executable.o files. Short-circuit this stuff. */
- ei->entry_point_p = 0;
+ ei->entry_point_p = false;
}
if (ei->entry_point_p)
next prev parent reply other threads:[~2026-04-17 15:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-15 20:25 [PATCH 0/2] Internal error for shared library with no .text section Andrew Burgess
2026-04-15 20:25 ` [PATCH 1/2] gdb: int to bool in struct entry_info Andrew Burgess
2026-04-17 15:16 ` Tom Tromey
2026-04-17 15:30 ` Andrew Burgess [this message]
2026-04-17 17:10 ` Tom Tromey
2026-04-15 20:25 ` [PATCH 2/2] gdb: don't use .text as default entry point section Andrew Burgess
2026-04-17 15:24 ` Tom Tromey
2026-04-17 20:44 ` Andrew Burgess
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=87cxzx4n9z.fsf@redhat.com \
--to=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.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