public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 04/18] Move works_in_software_mode to watchpoint
Date: Mon,  2 May 2022 16:15:39 -0600	[thread overview]
Message-ID: <20220502221553.1394743-5-tom@tromey.com> (raw)
In-Reply-To: <20220502221553.1394743-1-tom@tromey.com>

works_in_software_mode is only useful for watchpoints.  This patch
moves it from breakpoint to watchpoint, and changes it to return bool.
---
 gdb/breakpoint.c | 16 +++++-----------
 gdb/breakpoint.h | 12 ++++++------
 2 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 2521e95ce70..41e827bfca7 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -2144,7 +2144,7 @@ update_watchpoint (struct watchpoint *b, int reparse)
 		= target_can_use_hardware_watchpoint (type, i, other_type_used);
 	      if (target_resources_ok <= 0)
 		{
-		  int sw_mode = b->works_in_software_mode ();
+		  bool sw_mode = b->works_in_software_mode ();
 
 		  if (target_resources_ok == 0 && !sw_mode)
 		    error (_("Target does not support this type of "
@@ -9558,7 +9558,7 @@ watchpoint::resources_needed (const struct bp_location *bl)
 /* Implement the "works_in_software_mode" method for hardware
    watchpoints.  */
 
-int
+bool
 watchpoint::works_in_software_mode () const
 {
   /* Read and access watchpoints only work with hardware support.  */
@@ -9733,7 +9733,7 @@ struct masked_watchpoint : public watchpoint
   int remove_location (struct bp_location *,
 		       enum remove_bp_reason reason) override;
   int resources_needed (const struct bp_location *) override;
-  int works_in_software_mode () const override;
+  bool works_in_software_mode () const override;
   enum print_stop_action print_it (struct bpstat *bs) override;
   void print_one_detail (struct ui_out *) const override;
   void print_mention () override;
@@ -9771,10 +9771,10 @@ masked_watchpoint::resources_needed (const struct bp_location *bl)
 /* Implement the "works_in_software_mode" method for masked hardware
    watchpoints.  */
 
-int
+bool
 masked_watchpoint::works_in_software_mode () const
 {
-  return 0;
+  return false;
 }
 
 /* Implement the "print_it" method for masked hardware
@@ -11550,12 +11550,6 @@ breakpoint::breakpoint_hit (const struct bp_location *bl,
   internal_error_pure_virtual_called ();
 }
 
-int
-breakpoint::works_in_software_mode () const
-{
-  internal_error_pure_virtual_called ();
-}
-
 int
 breakpoint::resources_needed (const struct bp_location *bl)
 {
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index ec3a8309b51..bbacbca15fb 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -668,11 +668,6 @@ struct breakpoint
      the breakpoint or watchpoint needs one debug register.  */
   virtual int resources_needed (const struct bp_location *);
 
-  /* Tell whether we can downgrade from a hardware watchpoint to a software
-     one.  If not, the user will not be able to enable the watchpoint when
-     there are not enough hardware resources available.  */
-  virtual int works_in_software_mode () const;
-
   /* The normal print routine for this breakpoint, called when we
      hit it.  */
   virtual enum print_stop_action print_it (struct bpstat *bs);
@@ -878,7 +873,12 @@ struct watchpoint : public breakpoint
 		      const target_waitstatus &ws) override;
   void check_status (struct bpstat *bs) override;
   int resources_needed (const struct bp_location *) override;
-  int works_in_software_mode () const override;
+
+  /* Tell whether we can downgrade from a hardware watchpoint to a software
+     one.  If not, the user will not be able to enable the watchpoint when
+     there are not enough hardware resources available.  */
+  virtual bool works_in_software_mode () const;
+
   enum print_stop_action print_it (struct bpstat *bs) override;
   void print_mention () override;
   void print_recreate (struct ui_file *fp) override;
-- 
2.34.1


  parent reply	other threads:[~2022-05-02 22:15 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-02 22:15 [PATCH 00/18] Minor breakpoint cleanups Tom Tromey
2022-05-02 22:15 ` [PATCH 01/18] Change print_recreate_thread to a method Tom Tromey
2022-05-02 22:15 ` [PATCH 02/18] Remove breakpoint::ops Tom Tromey
2022-05-02 22:15 ` [PATCH 03/18] Boolify breakpoint::explains_signal Tom Tromey
2022-05-02 22:15 ` Tom Tromey [this message]
2022-05-02 22:15 ` [PATCH 05/18] Constify breakpoint::print_it Tom Tromey
2022-05-02 22:15 ` [PATCH 06/18] Constify breakpoint::print_one Tom Tromey
2022-05-02 22:15 ` [PATCH 07/18] Constify breakpoint::print_mention Tom Tromey
2022-05-02 22:15 ` [PATCH 08/18] Constify breakpoint::print_recreate Tom Tromey
2022-05-02 22:15 ` [PATCH 09/18] Remove unnecessary line from catch_exec_command_1 Tom Tromey
2022-05-02 22:15 ` [PATCH 10/18] Add constructor to fork_catchpoint Tom Tromey
2022-05-02 22:15 ` [PATCH 11/18] Add constructor to solib_catchpoint Tom Tromey
2022-05-02 22:15 ` [PATCH 12/18] Add constructor to signal_catchpoint Tom Tromey
2022-05-02 22:15 ` [PATCH 13/18] Add constructor to syscall_catchpoint Tom Tromey
2022-05-02 22:15 ` [PATCH 14/18] Add constructor to exception_catchpoint Tom Tromey
2022-05-02 22:15 ` [PATCH 15/18] Disable copying for breakpoint Tom Tromey
2022-05-02 22:15 ` [PATCH 16/18] Remove init_raw_breakpoint_without_location Tom Tromey
2022-05-03 19:26   ` Pedro Alves
2022-05-03 22:43     ` Tom Tromey
2022-05-02 22:15 ` [PATCH 17/18] Add initializers to tracepoint Tom Tromey
2022-05-02 22:15 ` [PATCH 18/18] Introduce catchpoint class Tom Tromey
2022-05-03 19:32   ` Pedro Alves
2022-05-03 23:02     ` Tom Tromey
2022-05-04 11:37       ` Pedro Alves
2022-05-07  2:19   ` Simon Marchi
2022-05-07 16:07     ` Tom Tromey
2022-05-07 19:31       ` Simon Marchi
2022-05-16 18:22         ` Tom Tromey
2022-05-16 19:29           ` Simon Marchi
2022-05-03 19:33 ` [PATCH 00/18] Minor breakpoint cleanups Pedro Alves
2022-05-06 18:03   ` 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=20220502221553.1394743-5-tom@tromey.com \
    --to=tom@tromey.com \
    --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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).