public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Minor bool-ification
@ 2022-11-11 22:57 Tom Tromey
  2022-11-11 22:57 ` [PATCH 1/2] Use bool constants for value_print_options Tom Tromey
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Tom Tromey @ 2022-11-11 22:57 UTC (permalink / raw)
  To: gdb-patches

I noticed a couple of areas that could benefit from some minor
bool-ification, and this series is the result.

Regression tested on x86-64 Fedora 34.

Tom



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] Use bool constants for value_print_options
  2022-11-11 22:57 [PATCH 0/2] Minor bool-ification Tom Tromey
@ 2022-11-11 22:57 ` Tom Tromey
  2022-11-11 22:57 ` [PATCH 2/2] Use bool in bpstat Tom Tromey
  2022-12-19 15:20 ` [PATCH 0/2] Minor bool-ification Tom Tromey
  2 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2022-11-11 22:57 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes the uses of value_print_options to use 'true' and 'false'
rather than integers.
---
 gdb/ada-valprint.c           | 10 +++++-----
 gdb/c-valprint.c             |  2 +-
 gdb/cp-valprint.c            |  6 +++---
 gdb/dwarf2/read.c            |  2 +-
 gdb/guile/scm-pretty-print.c |  6 +++---
 gdb/guile/scm-value.c        |  4 ++--
 gdb/infcmd.c                 |  6 +++---
 gdb/mi/mi-cmd-stack.c        |  2 +-
 gdb/mi/mi-main.c             |  8 ++++----
 gdb/p-valprint.c             |  8 ++++----
 gdb/printcmd.c               |  2 +-
 gdb/python/py-framefilter.c  |  6 +++---
 gdb/python/py-prettyprint.c  |  6 +++---
 gdb/python/py-value.c        |  4 ++--
 gdb/riscv-tdep.c             |  6 +++---
 gdb/rust-lang.c              |  6 +++---
 gdb/stack.c                  |  2 +-
 gdb/valprint.c               | 32 ++++++++++++++++----------------
 gdb/varobj.c                 |  2 +-
 19 files changed, 60 insertions(+), 60 deletions(-)

diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 40c26145224..92e96da4bec 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -209,7 +209,7 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
 	{
 	  struct value_print_options opts = *options;
 
-	  opts.deref_ref = 0;
+	  opts.deref_ref = false;
 	  common_val_print (v0, stream, recurse + 1, &opts, current_language);
 	  annotate_elt_rep (i - i0);
 	  gdb_printf (stream, _(" %p[<repeats %u times>%p]"),
@@ -222,7 +222,7 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
 	  int j;
 	  struct value_print_options opts = *options;
 
-	  opts.deref_ref = 0;
+	  opts.deref_ref = false;
 	  for (j = i0; j < i; j += 1)
 	    {
 	      if (j > i0)
@@ -658,7 +658,7 @@ print_field_values (struct value *value, struct value *outer_value,
 		     bit_pos % HOST_CHAR_BIT,
 		     bit_size, type->field (i).type ());
 	      opts = *options;
-	      opts.deref_ref = 0;
+	      opts.deref_ref = false;
 	      common_val_print (v, stream, recurse + 1, &opts, language);
 	    }
 	}
@@ -666,7 +666,7 @@ print_field_values (struct value *value, struct value *outer_value,
 	{
 	  struct value_print_options opts = *options;
 
-	  opts.deref_ref = 0;
+	  opts.deref_ref = false;
 
 	  struct value *v = value_field (value, i);
 	  common_val_print (v, stream, recurse + 1, &opts, language);
@@ -1127,6 +1127,6 @@ ada_value_print (struct value *val0, struct ui_file *stream,
     }
 
   opts = *options;
-  opts.deref_ref = 1;
+  opts.deref_ref = true;
   common_val_print (val, stream, 0, &opts, current_language);
 }
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 9b73d973cd5..994168fc01d 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -476,7 +476,7 @@ c_value_print (struct value *val, struct ui_file *stream,
   LONGEST top;
   struct value_print_options opts = *options;
 
-  opts.deref_ref = 1;
+  opts.deref_ref = true;
 
   /* If it is a pointer, indicate what it points to.
 
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index fac558deb05..1c8c4995d96 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -279,7 +279,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
 		}
 	      else
 		{
-		  opts->deref_ref = 0;
+		  opts->deref_ref = false;
 
 		  v = value_field_bitfield (type, i, valaddr,
 					    value_embedded_offset (val), val);
@@ -331,7 +331,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
 	      else
 		{
 		  struct value *v = value_primitive_field (val, 0, i, type);
-		  opts->deref_ref = 0;
+		  opts->deref_ref = false;
 		  common_val_print (v, stream, recurse + 1, opts,
 				    current_language);
 		}
@@ -613,7 +613,7 @@ cp_print_static_field (struct type *type,
     }
 
   opts = *options;
-  opts.deref_ref = 0;
+  opts.deref_ref = false;
   common_val_print (val, stream, recurse, &opts, current_language);
 }
 
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 60e120a9d76..a9862555a6a 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -9037,7 +9037,7 @@ dwarf2_compute_name (const char *name,
 		      /* Specify decimal so that we do not depend on
 			 the radix.  */
 		      get_formatted_print_options (&opts, 'd');
-		      opts.raw = 1;
+		      opts.raw = true;
 		      value_print (v, &buf, &opts);
 		      release_value (v);
 		    }
diff --git a/gdb/guile/scm-pretty-print.c b/gdb/guile/scm-pretty-print.c
index 5e6bb12a3a5..9e42a4d6178 100644
--- a/gdb/guile/scm-pretty-print.c
+++ b/gdb/guile/scm-pretty-print.c
@@ -660,7 +660,7 @@ ppscm_print_string_repr (SCM printer, enum display_hint hint,
       struct value_print_options opts = *options;
 
       gdb_assert (replacement != NULL);
-      opts.addressprint = 0;
+      opts.addressprint = false;
       common_val_print (replacement, stream, recurse, &opts, language);
       result = STRING_REPR_OK;
     }
@@ -698,7 +698,7 @@ ppscm_print_string_repr (SCM printer, enum display_hint hint,
     {
       struct value_print_options local_opts = *options;
 
-      local_opts.addressprint = 0;
+      local_opts.addressprint = false;
       lsscm_val_print_lazy_string (str_scm, stream, &local_opts);
       result = STRING_REPR_OK;
     }
@@ -883,7 +883,7 @@ ppscm_print_children (SCM printer, enum display_hint hint,
 	{
 	  struct value_print_options local_opts = *options;
 
-	  local_opts.addressprint = 0;
+	  local_opts.addressprint = false;
 	  lsscm_val_print_lazy_string (v_scm, stream, &local_opts);
 	}
       else if (scm_is_string (v_scm))
diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c
index 0107a4bd320..8ff2823ab19 100644
--- a/gdb/guile/scm-value.c
+++ b/gdb/guile/scm-value.c
@@ -148,7 +148,7 @@ vlscm_print_value_smob (SCM self, SCM port, scm_print_state *pstate)
     gdbscm_printf (port, "#<%s ", value_smob_name);
 
   get_user_print_options (&opts);
-  opts.deref_ref = 0;
+  opts.deref_ref = false;
 
   /* pstate->writingp = zero if invoked by display/~A, and nonzero if
      invoked by write/~S.  What to do here may need to evolve.
@@ -1264,7 +1264,7 @@ gdbscm_value_print (SCM self)
   struct value_print_options opts;
 
   get_user_print_options (&opts);
-  opts.deref_ref = 0;
+  opts.deref_ref = false;
 
   string_file stb;
 
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index bf4a68e3557..a25eb388fdc 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -2150,7 +2150,7 @@ default_print_one_register_info (struct ui_file *file,
       enum bfd_endian byte_order = type_byte_order (regtype);
 
       get_user_print_options (&opts);
-      opts.deref_ref = 1;
+      opts.deref_ref = true;
 
       common_val_print (val, &format_stream, 0, &opts, current_language);
 
@@ -2169,7 +2169,7 @@ default_print_one_register_info (struct ui_file *file,
 
       /* Print the register in hex.  */
       get_formatted_print_options (&opts, 'x');
-      opts.deref_ref = 1;
+      opts.deref_ref = true;
       common_val_print (val, &format_stream, 0, &opts, current_language);
       /* If not a vector register, print it also according to its
 	 natural format.  */
@@ -2177,7 +2177,7 @@ default_print_one_register_info (struct ui_file *file,
 	{
 	  pad_to_column (format_stream, value_column_2);
 	  get_user_print_options (&opts);
-	  opts.deref_ref = 1;
+	  opts.deref_ref = true;
 	  common_val_print (val, &format_stream, 0, &opts, current_language);
 	}
     }
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index f0af7c9a014..b14f41d403c 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -545,7 +545,7 @@ list_arg_or_local (const struct frame_arg *arg, enum what_to_list what,
 	      struct value_print_options opts;
 
 	      get_no_prettyformat_print_options (&opts);
-	      opts.deref_ref = 1;
+	      opts.deref_ref = true;
 	      common_val_print (arg->val, &stb, 0, &opts,
 				language_def (arg->sym->language ()));
 	    }
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index e5b003ec99b..204669db91c 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -1111,7 +1111,7 @@ output_register (frame_info_ptr frame, int regnum, int format,
   string_file stb;
 
   get_formatted_print_options (&opts, format);
-  opts.deref_ref = 1;
+  opts.deref_ref = true;
   common_val_print (val, &stb, 0, &opts, current_language);
   uiout->field_stream ("value", stb);
 }
@@ -1195,7 +1195,7 @@ mi_cmd_data_evaluate_expression (const char *command, char **argv, int argc)
 
   /* Print the result of the expression evaluation.  */
   get_user_print_options (&opts);
-  opts.deref_ref = 0;
+  opts.deref_ref = false;
   common_val_print (val, &stb, 0, &opts, current_language);
 
   uiout->field_stream ("value", stb);
@@ -2485,7 +2485,7 @@ print_variable_or_computed (const char *expression, enum print_values values)
 	  struct value_print_options opts;
 
 	  get_no_prettyformat_print_options (&opts);
-	  opts.deref_ref = 1;
+	  opts.deref_ref = true;
 	  common_val_print (val, &stb, 0, &opts, current_language);
 	  uiout->field_stream ("value", stb);
 	}
@@ -2495,7 +2495,7 @@ print_variable_or_computed (const char *expression, enum print_values values)
 	struct value_print_options opts;
 
 	get_no_prettyformat_print_options (&opts);
-	opts.deref_ref = 1;
+	opts.deref_ref = true;
 	common_val_print (val, &stb, 0, &opts, current_language);
 	uiout->field_stream ("value", stb);
       }
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index 2786a8e8c86..b74c424350f 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -408,7 +408,7 @@ pascal_language::value_print (struct value *val, struct ui_file *stream,
   struct type *type = value_type (val);
   struct value_print_options opts = *options;
 
-  opts.deref_ref = 1;
+  opts.deref_ref = true;
 
   /* If it is a pointer, indicate what it points to.
 
@@ -619,7 +619,7 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream,
 
 		  v = value_field_bitfield (type, i, valaddr, 0, val);
 
-		  opts.deref_ref = 0;
+		  opts.deref_ref = false;
 		  common_val_print (v, stream, recurse + 1, &opts,
 				    current_language);
 		}
@@ -649,7 +649,7 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream,
 		{
 		  struct value_print_options opts = *options;
 
-		  opts.deref_ref = 0;
+		  opts.deref_ref = false;
 
 		  struct value *v = value_primitive_field (val, 0, i,
 							   value_type (val));
@@ -853,7 +853,7 @@ pascal_object_print_static_field (struct value *val,
     }
 
   opts = *options;
-  opts.deref_ref = 0;
+  opts.deref_ref = false;
   common_val_print (val, stream, recurse, &opts, current_language);
 }
 
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 273aa5931a9..60921415abd 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -2400,7 +2400,7 @@ print_variable_and_value (const char *name, struct symbol *var,
 	 a block to it.  */
       val = read_var_value (var, NULL, frame);
       get_user_print_options (&opts);
-      opts.deref_ref = 1;
+      opts.deref_ref = true;
       common_val_print_checked (val, stream, indent, &opts, current_language);
 
       /* common_val_print invalidates FRAME when a pretty printer calls inferior
diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c
index 0d7dc48c5a0..30968d1f550 100644
--- a/gdb/python/py-framefilter.c
+++ b/gdb/python/py-framefilter.c
@@ -428,10 +428,10 @@ enumerate_args (PyObject *iter,
   if (args_type == CLI_SCALAR_VALUES)
     {
       /* True in "summary" mode, false otherwise.  */
-      opts.summary = 1;
+      opts.summary = true;
     }
 
-  opts.deref_ref = 1;
+  opts.deref_ref = true;
 
   annotate_frame_args ();
 
@@ -555,7 +555,7 @@ enumerate_locals (PyObject *iter,
   struct value_print_options opts;
 
   get_user_print_options (&opts);
-  opts.deref_ref = 1;
+  opts.deref_ref = true;
 
   while (true)
     {
diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c
index 9276807341e..eb3a3fdd4f6 100644
--- a/gdb/python/py-prettyprint.c
+++ b/gdb/python/py-prettyprint.c
@@ -303,7 +303,7 @@ print_string_repr (PyObject *printer, const char *hint,
 	  gdbpy_extract_lazy_string (py_str.get (), &addr, &type,
 				     &length, &encoding);
 
-	  local_opts.addressprint = 0;
+	  local_opts.addressprint = false;
 	  val_print_string (type, encoding.get (), addr, (int) length,
 			    stream, &local_opts);
 	}
@@ -338,7 +338,7 @@ print_string_repr (PyObject *printer, const char *hint,
     {
       struct value_print_options opts = *options;
 
-      opts.addressprint = 0;
+      opts.addressprint = false;
       common_val_print (replacement, stream, recurse, &opts, language);
     }
   else
@@ -506,7 +506,7 @@ print_children (PyObject *printer, const char *hint,
 
 	  gdbpy_extract_lazy_string (py_v, &addr, &type, &length, &encoding);
 
-	  local_opts.addressprint = 0;
+	  local_opts.addressprint = false;
 	  val_print_string (type, encoding.get (), addr, (int) length, stream,
 			    &local_opts);
 	}
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index 92a15304c34..44b4ebcf4e4 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -675,7 +675,7 @@ valpy_format_string (PyObject *self, PyObject *args, PyObject *kw)
 
   struct value_print_options opts;
   gdbpy_get_print_options (&opts);
-  opts.deref_ref = 0;
+  opts.deref_ref = false;
 
   /* We need objects for booleans as the "p" flag for bools is new in
      Python 3.3.  */
@@ -1169,7 +1169,7 @@ valpy_str (PyObject *self)
   struct value_print_options opts;
 
   gdbpy_get_print_options (&opts);
-  opts.deref_ref = 0;
+  opts.deref_ref = false;
 
   string_file stb;
 
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index 0a050b272ff..95e1cc5b500 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -1146,7 +1146,7 @@ riscv_print_one_register_info (struct gdbarch *gdbarch,
       enum bfd_endian byte_order = type_byte_order (regtype);
 
       get_user_print_options (&opts);
-      opts.deref_ref = 1;
+      opts.deref_ref = true;
 
       common_val_print (val, file, 0, &opts, current_language);
 
@@ -1165,7 +1165,7 @@ riscv_print_one_register_info (struct gdbarch *gdbarch,
 
       /* Print the register in hex.  */
       get_formatted_print_options (&opts, 'x');
-      opts.deref_ref = 1;
+      opts.deref_ref = true;
       common_val_print (val, file, 0, &opts, current_language);
 
       if (print_raw_format)
@@ -1298,7 +1298,7 @@ riscv_print_one_register_info (struct gdbarch *gdbarch,
 	      if (regtype->is_vector () == 0)
 		{
 		  get_user_print_options (&opts);
-		  opts.deref_ref = 1;
+		  opts.deref_ref = true;
 		  gdb_printf (file, "\t");
 		  common_val_print (val, file, 0, &opts, current_language);
 		}
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 8673a908698..f26d4c398b7 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -398,7 +398,7 @@ rust_language::val_print_struct
     gdb_puts ("{", stream);
 
   opts = *options;
-  opts.deref_ref = 0;
+  opts.deref_ref = false;
 
   first_field = 1;
   for (i = 0; i < type->num_fields (); ++i)
@@ -452,7 +452,7 @@ rust_language::print_enum (struct value *val, struct ui_file *stream,
   struct value_print_options opts = *options;
   struct type *type = check_typedef (value_type (val));
 
-  opts.deref_ref = 0;
+  opts.deref_ref = false;
 
   gdb_assert (rust_enum_p (type));
   gdb::array_view<const gdb_byte> view
@@ -524,7 +524,7 @@ rust_language::value_print_inner
 	 const struct value_print_options *options) const
 {
   struct value_print_options opts = *options;
-  opts.deref_ref = 1;
+  opts.deref_ref = true;
 
   if (opts.prettyformat == Val_prettyformat_default)
     opts.prettyformat = (opts.prettyformat_structs
diff --git a/gdb/stack.c b/gdb/stack.c
index 4ad51c2eb50..efe44ebee5c 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -479,7 +479,7 @@ print_frame_arg (const frame_print_options &fp_opts,
 		language = current_language;
 
 	      get_no_prettyformat_print_options (&vp_opts);
-	      vp_opts.deref_ref = 1;
+	      vp_opts.deref_ref = true;
 	      vp_opts.raw = fp_opts.print_raw_frame_arguments;
 
 	      /* True in "summary" mode, false otherwise.  */
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 48d611ecf8a..1a73d27d0c2 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -100,26 +100,26 @@ static void val_print_type_code_flags (struct type *type,
 struct value_print_options user_print_options =
 {
   Val_prettyformat_default,	/* prettyformat */
-  0,				/* prettyformat_arrays */
-  0,				/* prettyformat_structs */
-  0,				/* vtblprint */
-  1,				/* unionprint */
-  1,				/* addressprint */
+  false,			/* prettyformat_arrays */
+  false,			/* prettyformat_structs */
+  false,			/* vtblprint */
+  true,				/* unionprint */
+  true,				/* addressprint */
   false,			/* nibblesprint */
-  0,				/* objectprint */
+  false,			/* objectprint */
   PRINT_MAX_DEFAULT,		/* print_max */
   10,				/* repeat_count_threshold */
   0,				/* output_format */
   0,				/* format */
-  1,				/* memory_tag_violations */
-  0,				/* stop_print_at_null */
-  0,				/* print_array_indexes */
-  0,				/* deref_ref */
-  1,				/* static_field_print */
-  1,				/* pascal_static_field_print */
-  0,				/* raw */
-  0,				/* summary */
-  1,				/* symbol_print */
+  true,				/* memory_tag_violations */
+  false,			/* stop_print_at_null */
+  false,			/* print_array_indexes */
+  false,			/* deref_ref */
+  true,				/* static_field_print */
+  true,				/* pascal_static_field_print */
+  false,			/* raw */
+  false,			/* summary */
+  true,				/* symbol_print */
   PRINT_MAX_DEPTH_DEFAULT,	/* max_depth */
 };
 
@@ -1272,7 +1272,7 @@ value_print_scalar_formatted (struct value *val,
     {
       struct value_print_options opts = *options;
       opts.format = 0;
-      opts.deref_ref = 0;
+      opts.deref_ref = false;
       common_val_print (val, stream, 0, &opts, current_language);
       return;
     }
diff --git a/gdb/varobj.c b/gdb/varobj.c
index 467f9ff3a26..6ed5b7049bc 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -2144,7 +2144,7 @@ varobj_formatted_print_options (struct value_print_options *opts,
 				enum varobj_display_formats format)
 {
   get_formatted_print_options (opts, format_code[(int) format]);
-  opts->deref_ref = 0;
+  opts->deref_ref = false;
   opts->raw = !pretty_printing;
 }
 
-- 
2.34.3


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/2] Use bool in bpstat
  2022-11-11 22:57 [PATCH 0/2] Minor bool-ification Tom Tromey
  2022-11-11 22:57 ` [PATCH 1/2] Use bool constants for value_print_options Tom Tromey
@ 2022-11-11 22:57 ` Tom Tromey
  2022-12-19 15:20 ` [PATCH 0/2] Minor bool-ification Tom Tromey
  2 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2022-11-11 22:57 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes bpstat to use 'bool' rather than 'char', and updates the
uses.
---
 gdb/break-catch-load.c  |  2 +-
 gdb/break-catch-throw.c |  4 ++--
 gdb/breakpoint.c        | 38 +++++++++++++++++++-------------------
 gdb/breakpoint.h        | 11 ++++++-----
 gdb/extension.c         |  4 ++--
 gdb/extension.h         |  2 +-
 6 files changed, 31 insertions(+), 30 deletions(-)

diff --git a/gdb/break-catch-load.c b/gdb/break-catch-load.c
index 617ee2b694d..58764218401 100644
--- a/gdb/break-catch-load.c
+++ b/gdb/break-catch-load.c
@@ -134,7 +134,7 @@ solib_catchpoint::check_status (struct bpstat *bs)
 	}
     }
 
-  bs->stop = 0;
+  bs->stop = false;
   bs->print_it = print_it_noop;
 }
 
diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
index 6557ee71449..66432552db6 100644
--- a/gdb/break-catch-throw.c
+++ b/gdb/break-catch-throw.c
@@ -172,7 +172,7 @@ exception_catchpoint::check_status (struct bpstat *bs)
   std::string type_name;
 
   this->breakpoint::check_status (bs);
-  if (bs->stop == 0)
+  if (!bs->stop)
     return;
 
   if (self->pattern == NULL)
@@ -200,7 +200,7 @@ exception_catchpoint::check_status (struct bpstat *bs)
   if (name != nullptr)
     {
       if (self->pattern->exec (name, 0, NULL, 0) != 0)
-	bs->stop = 0;
+	bs->stop = false;
     }
 }
 
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 490708938ec..e7fec0eefd9 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -5127,7 +5127,7 @@ bpstat_check_location (const struct bp_location *bl,
 }
 
 /* Determine if the watched values have actually changed, and we
-   should stop.  If not, set BS->stop to 0.  */
+   should stop.  If not, set BS->stop to false.  */
 
 static void
 bpstat_check_watchpoint (bpstat *bs)
@@ -5194,7 +5194,7 @@ bpstat_check_watchpoint (bpstat *bs)
 	      break;
 	    case WP_IGNORE:
 	      bs->print_it = print_it_noop;
-	      bs->stop = 0;
+	      bs->stop = false;
 	      break;
 	    case WP_VALUE_CHANGED:
 	      if (b->type == bp_read_watchpoint)
@@ -5261,7 +5261,7 @@ bpstat_check_watchpoint (bpstat *bs)
 			 updated it, so this trap must be for a write.
 			 Ignore it.  */
 		      bs->print_it = print_it_noop;
-		      bs->stop = 0;
+		      bs->stop = false;
 		    }
 		}
 	      break;
@@ -5272,7 +5272,7 @@ bpstat_check_watchpoint (bpstat *bs)
 		  /* Don't stop: write watchpoints shouldn't fire if
 		     the value hasn't changed.  */
 		  bs->print_it = print_it_noop;
-		  bs->stop = 0;
+		  bs->stop = false;
 		}
 	      /* Stop.  */
 	      break;
@@ -5288,7 +5288,7 @@ bpstat_check_watchpoint (bpstat *bs)
 	     watchpoint triggered after all.  So don't print
 	     anything for this watchpoint.  */
 	  bs->print_it = print_it_noop;
-	  bs->stop = 0;
+	  bs->stop = false;
 	}
     }
 }
@@ -5331,7 +5331,7 @@ bpstat_check_breakpoint_conditions (bpstat *bs, thread_info *thread)
       infrun_debug_printf ("incorrect frame %s not %s, not stopping",
 			   get_stack_frame_id (get_current_frame ()).to_string ().c_str (),
 			   b->frame_id.to_string ().c_str ());
-      bs->stop = 0;
+      bs->stop = false;
       return;
     }
 
@@ -5342,7 +5342,7 @@ bpstat_check_breakpoint_conditions (bpstat *bs, thread_info *thread)
       || (b->task != 0 && b->task != ada_get_task_number (thread)))
     {
       infrun_debug_printf ("incorrect thread or task, not stopping");
-      bs->stop = 0;
+      bs->stop = false;
       return;
     }
 
@@ -5432,7 +5432,7 @@ bpstat_check_breakpoint_conditions (bpstat *bs, thread_info *thread)
   if (cond != nullptr && !condition_result)
     {
       infrun_debug_printf ("condition_result = false, not stopping");
-      bs->stop = 0;
+      bs->stop = false;
       return;
     }
   else if (b->ignore_count > 0)
@@ -5440,7 +5440,7 @@ bpstat_check_breakpoint_conditions (bpstat *bs, thread_info *thread)
       infrun_debug_printf ("ignore count %d, not stopping",
 			   b->ignore_count);
       b->ignore_count--;
-      bs->stop = 0;
+      bs->stop = false;
       /* Increase the hit count even though we don't stop.  */
       ++(b->hit_count);
       gdb::observers::breakpoint_modified.notify (b);
@@ -5503,8 +5503,8 @@ build_bpstat_chain (const address_space *aspace, CORE_ADDR bp_addr,
 	  /* Assume we stop.  Should we find a watchpoint that is not
 	     actually triggered, or if the condition of the breakpoint
 	     evaluates as false, we'll reset 'stop' to 0.  */
-	  bs->stop = 1;
-	  bs->print = 1;
+	  bs->stop = true;
+	  bs->print = true;
 
 	  /* If this is a scope breakpoint, mark the associated
 	     watchpoint as triggered so that we will handle the
@@ -5530,8 +5530,8 @@ build_bpstat_chain (const address_space *aspace, CORE_ADDR bp_addr,
 	    {
 	      bpstat *bs = new bpstat (loc, &bs_link);
 	      /* For hits of moribund locations, we should just proceed.  */
-	      bs->stop = 0;
-	      bs->print = 0;
+	      bs->stop = false;
+	      bs->print = false;
 	      bs->print_it = print_it_noop;
 	    }
 	}
@@ -5608,11 +5608,11 @@ bpstat_stop_status (const address_space *aspace,
 		}
 	      gdb::observers::breakpoint_modified.notify (b);
 	      if (b->silent)
-		bs->print = 0;
+		bs->print = false;
 	      bs->commands = b->commands;
 	      if (command_line_is_silent (bs->commands
 					  ? bs->commands.get () : NULL))
-		bs->print = 0;
+		bs->print = false;
 
 	      b->after_condition_true (bs);
 	    }
@@ -11754,11 +11754,11 @@ internal_breakpoint::check_status (bpstat *bs)
 	 events.  This allows the user to get control and place
 	 breakpoints in initializer routines for dynamically loaded
 	 objects (among other things).  */
-      bs->stop = stop_on_solib_events;
-      bs->print = stop_on_solib_events;
+      bs->stop = stop_on_solib_events != 0;
+      bs->print = stop_on_solib_events != 0;
     }
   else
-    bs->stop = 0;
+    bs->stop = false;
 }
 
 enum print_stop_action
@@ -12005,7 +12005,7 @@ dprintf_breakpoint::after_condition_true (struct bpstat *bs)
   /* dprintf's never cause a stop.  This wasn't set in the
      check_status hook instead because that would make the dprintf's
      condition not be evaluated.  */
-  bs->stop = 0;
+  bs->stop = false;
 
   /* Run the command list here.  Take ownership of it instead of
      copying.  We never want these commands to run later in
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 360fa760577..305c50c1c34 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -664,7 +664,8 @@ struct breakpoint
 			      const target_waitstatus &ws);
 
   /* Check internal conditions of the breakpoint referred to by BS.
-     If we should not stop for this breakpoint, set BS->stop to 0.  */
+     If we should not stop for this breakpoint, set BS->stop to
+     false.  */
   virtual void check_status (struct bpstat *bs)
   {
     /* Always stop.  */
@@ -1312,11 +1313,11 @@ struct bpstat
     /* Old value associated with a watchpoint.  */
     value_ref_ptr old_val;
 
-    /* Nonzero if this breakpoint tells us to print the frame.  */
-    char print;
+    /* True if this breakpoint tells us to print the frame.  */
+    bool print;
 
-    /* Nonzero if this breakpoint tells us to stop.  */
-    char stop;
+    /* True if this breakpoint tells us to stop.  */
+    bool stop;
 
     /* Tell bpstat_print and print_bp_stop_message how to print stuff
        associated with this element of the bpstat chain.  */
diff --git a/gdb/extension.c b/gdb/extension.c
index 8cbd80f45d5..ca6305a3f43 100644
--- a/gdb/extension.c
+++ b/gdb/extension.c
@@ -597,7 +597,7 @@ get_breakpoint_cond_ext_lang (struct breakpoint *b,
 /* Return whether a stop condition for breakpoint B says to stop.
    True is also returned if there is no stop condition for B.  */
 
-int
+bool
 breakpoint_ext_lang_cond_says_stop (struct breakpoint *b)
 {
   enum ext_lang_bp_stop stop = EXT_LANG_BP_STOP_UNSET;
@@ -626,7 +626,7 @@ breakpoint_ext_lang_cond_says_stop (struct breakpoint *b)
 	}
     }
 
-  return stop == EXT_LANG_BP_STOP_NO ? 0 : 1;
+  return stop != EXT_LANG_BP_STOP_NO;
 }
 \f
 /* ^C/SIGINT support.
diff --git a/gdb/extension.h b/gdb/extension.h
index 72cff218f5b..7586b3c9eca 100644
--- a/gdb/extension.h
+++ b/gdb/extension.h
@@ -300,7 +300,7 @@ extern void preserve_ext_lang_values (struct objfile *, htab_t copied_types);
 extern const struct extension_language_defn *get_breakpoint_cond_ext_lang
   (struct breakpoint *b, enum extension_language skip_lang);
 
-extern int breakpoint_ext_lang_cond_says_stop (struct breakpoint *);
+extern bool breakpoint_ext_lang_cond_says_stop (struct breakpoint *);
 
 /* If a method with name METHOD_NAME is to be invoked on an object of type
    TYPE, then all extension languages are searched for implementations of
-- 
2.34.3


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] Minor bool-ification
  2022-11-11 22:57 [PATCH 0/2] Minor bool-ification Tom Tromey
  2022-11-11 22:57 ` [PATCH 1/2] Use bool constants for value_print_options Tom Tromey
  2022-11-11 22:57 ` [PATCH 2/2] Use bool in bpstat Tom Tromey
@ 2022-12-19 15:20 ` Tom Tromey
  2 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2022-12-19 15:20 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:

Tom> I noticed a couple of areas that could benefit from some minor
Tom> bool-ification, and this series is the result.

Tom> Regression tested on x86-64 Fedora 34.

I'm checking these in now.

Tom

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-12-19 15:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-11 22:57 [PATCH 0/2] Minor bool-ification Tom Tromey
2022-11-11 22:57 ` [PATCH 1/2] Use bool constants for value_print_options Tom Tromey
2022-11-11 22:57 ` [PATCH 2/2] Use bool in bpstat Tom Tromey
2022-12-19 15:20 ` [PATCH 0/2] Minor bool-ification Tom Tromey

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).