public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb: some int to bool conversion
@ 2023-01-24 3:20 Enze Li
0 siblings, 0 replies; 2+ messages in thread
From: Enze Li @ 2023-01-24 3:20 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=59d49a8d83a289624a1dff4e8833f2b7c286d764
commit 59d49a8d83a289624a1dff4e8833f2b7c286d764
Author: Enze Li <enze.li@hotmail.com>
Date: Sun Jan 22 13:38:41 2023 +0800
gdb: some int to bool conversion
When building GDB with clang 16, I got this,
CXX maint.o
maint.c:1045:23: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
m_space_enabled = 1;
^ ~
maint.c:1057:22: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
m_time_enabled = 1;
^ ~
maint.c:1073:24: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
m_symtab_enabled = 1;
^ ~
3 errors generated.
Work around this by using bool bitfields instead.
Tested by rebuilding on x86_64-linux with clang 16 and gcc 12.
Approved-By: Tom Tromey <tom@tromey.com>
Diff:
---
gdb/maint.c | 12 ++++++------
gdb/maint.h | 6 +++---
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/gdb/maint.c b/gdb/maint.c
index 1a226bf75e3..52f91a3246f 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -1042,11 +1042,11 @@ scoped_command_stats::scoped_command_stats (bool msg_type)
#ifdef HAVE_USEFUL_SBRK
char *lim = (char *) sbrk (0);
m_start_space = lim - lim_at_start;
- m_space_enabled = 1;
+ m_space_enabled = true;
#endif
}
else
- m_space_enabled = 0;
+ m_space_enabled = false;
if (msg_type == 0 || per_command_time)
{
@@ -1054,13 +1054,13 @@ scoped_command_stats::scoped_command_stats (bool msg_type)
m_start_cpu_time = run_time_clock::now ();
m_start_wall_time = steady_clock::now ();
- m_time_enabled = 1;
+ m_time_enabled = true;
if (per_command_time)
print_time (_("command started"));
}
else
- m_time_enabled = 0;
+ m_time_enabled = false;
if (msg_type == 0 || per_command_symtab)
{
@@ -1070,10 +1070,10 @@ scoped_command_stats::scoped_command_stats (bool msg_type)
m_start_nr_symtabs = nr_symtabs;
m_start_nr_compunit_symtabs = nr_compunit_symtabs;
m_start_nr_blocks = nr_blocks;
- m_symtab_enabled = 1;
+ m_symtab_enabled = true;
}
else
- m_symtab_enabled = 0;
+ m_symtab_enabled = false;
/* Initialize timer to keep track of how long we waited for the user. */
reset_prompt_for_continue_wait_time ();
diff --git a/gdb/maint.h b/gdb/maint.h
index 09a68c17bef..1741d132567 100644
--- a/gdb/maint.h
+++ b/gdb/maint.h
@@ -49,9 +49,9 @@ class scoped_command_stats
/* Track whether the stat was enabled at the start of the command
so that we can avoid printing anything if it gets turned on by
the current command. */
- int m_time_enabled : 1;
- int m_space_enabled : 1;
- int m_symtab_enabled : 1;
+ bool m_time_enabled : 1;
+ bool m_space_enabled : 1;
+ bool m_symtab_enabled : 1;
run_time_clock::time_point m_start_cpu_time;
std::chrono::steady_clock::time_point m_start_wall_time;
long m_start_space;
^ permalink raw reply [flat|nested] 2+ messages in thread
* [binutils-gdb] gdb: some int to bool conversion
@ 2021-05-07 16:01 Andrew Burgess
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Burgess @ 2021-05-07 16:01 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8a82de5884386be4c10f16eb55a94993ac6ea858
commit 8a82de5884386be4c10f16eb55a94993ac6ea858
Author: Andrew Burgess <andrew.burgess@embecosm.com>
Date: Fri May 7 16:49:24 2021 +0100
gdb: some int to bool conversion
Change int parameter to bool in remote_notice_new_inferior (remote.c)
and notice_new_inferior (infcmd.c), and update the callers.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* infcmd.c (notice_new_inferior): Change parameter type.
* inferior.h (notice_new_inferior): Change parameter type.
* remote.c (remote_notice_new_inferior): Change parameter type to
bool. Also update type of local variable to bool.
(remote_target::update_thread_list): Change type of local variable
to bool.
(remote_target::process_stop_reply): Pass bool instead of int to
remote_notice_new_inferior.
Diff:
---
gdb/ChangeLog | 11 +++++++++++
gdb/infcmd.c | 2 +-
gdb/inferior.h | 2 +-
gdb/remote.c | 10 +++++-----
4 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e75eb04247b..9c7fdc3abcf 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,14 @@
+2021-05-07 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * infcmd.c (notice_new_inferior): Change parameter type.
+ * inferior.h (notice_new_inferior): Change parameter type.
+ * remote.c (remote_notice_new_inferior): Change parameter type to
+ bool. Also update type of local variable to bool.
+ (remote_target::update_thread_list): Change type of local variable
+ to bool.
+ (remote_target::process_stop_reply): Pass bool instead of int to
+ remote_notice_new_inferior.
+
2021-05-07 Simon Marchi <simon.marchi@efficios.com>
* target.c (target_stack::unpush): Call target_ops::find_beneath
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 5d9d79261ef..f0b044d62b9 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -2675,7 +2675,7 @@ attach_command (const char *args, int from_tty)
as stopped. */
void
-notice_new_inferior (thread_info *thr, int leave_running, int from_tty)
+notice_new_inferior (thread_info *thr, bool leave_running, int from_tty)
{
enum attach_post_wait_mode mode
= leave_running ? ATTACH_POST_WAIT_RESUME : ATTACH_POST_WAIT_NOTHING;
diff --git a/gdb/inferior.h b/gdb/inferior.h
index 4a143c3a2b8..f4b8b025e35 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -218,7 +218,7 @@ using delete_longjmp_breakpoint_cleanup
extern void detach_command (const char *, int);
-extern void notice_new_inferior (struct thread_info *, int, int);
+extern void notice_new_inferior (struct thread_info *, bool, int);
extern struct value *get_return_value (struct value *function,
struct type *value_type);
diff --git a/gdb/remote.c b/gdb/remote.c
index a7312a9fc2d..d3a66599122 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -764,7 +764,7 @@ public: /* Remote specific methods. */
ptid_t select_thread_for_ambiguous_stop_reply
(const struct target_waitstatus *status);
- void remote_notice_new_inferior (ptid_t currthread, int executing);
+ void remote_notice_new_inferior (ptid_t currthread, bool executing);
void process_initial_stop_replies (int from_tty);
@@ -2556,12 +2556,12 @@ remote_target::remote_add_thread (ptid_t ptid, bool running, bool executing)
thread is (internally) executing or stopped. */
void
-remote_target::remote_notice_new_inferior (ptid_t currthread, int executing)
+remote_target::remote_notice_new_inferior (ptid_t currthread, bool executing)
{
/* In non-stop mode, we assume new found threads are (externally)
running until proven otherwise with a stop reply. In all-stop,
we can only get here if all threads are stopped. */
- int running = target_is_non_stop_p () ? 1 : 0;
+ bool running = target_is_non_stop_p ();
/* If this is a new thread, add it to GDB's thread list.
If we leave it up to WFI to do this, bad things will happen. */
@@ -3955,7 +3955,7 @@ remote_target::update_thread_list ()
executing until proven otherwise with a stop reply.
In all-stop, we can only get here if all threads are
stopped. */
- int executing = target_is_non_stop_p () ? 1 : 0;
+ bool executing = target_is_non_stop_p ();
remote_notice_new_inferior (item.ptid, executing);
@@ -8036,7 +8036,7 @@ remote_target::process_stop_reply (struct stop_reply *stop_reply,
stop_reply->regcache.clear ();
}
- remote_notice_new_inferior (ptid, 0);
+ remote_notice_new_inferior (ptid, false);
remote_thread_info *remote_thr = get_remote_thread_info (this, ptid);
remote_thr->core = stop_reply->core;
remote_thr->stop_reason = stop_reply->stop_reason;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-01-24 3:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-24 3:20 [binutils-gdb] gdb: some int to bool conversion Enze Li
-- strict thread matches above, loose matches on Subject: below --
2021-05-07 16:01 Andrew Burgess
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).