[1/4] gdb: make some bp_location arguments const in breakpoint.c

Message ID 0c8a73fc82f77704a4a065b0b251911aebae1322.1664962269.git.aburgess@redhat.com
State Committed
Headers
Series Const args, int->bool, and scoped_restore in breakpoint.c |

Commit Message

Andrew Burgess Oct. 5, 2022, 9:32 a.m. UTC
  I spotted a few places where I could make some 'bp_location *'
arguments constant in breakpoint.c.

There should be no user visible changes after this commit.
---
 gdb/breakpoint.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)
  

Comments

Guinevere Larsen Oct. 18, 2022, 1:46 p.m. UTC | #1
On 05/10/2022 11:32, Andrew Burgess via Gdb-patches wrote:
> I spotted a few places where I could make some 'bp_location *'
> arguments constant in breakpoint.c.
>
> There should be no user visible changes after this commit.

Hi Andrew,

This patch no longer applies, because of commit 
d8a77e4c8043c645c3c7a07a042c112053715e95, which already made the change 
to find_loc_num_by_location.

Other than this, this patch looks ok to me.

Reviewed-By: Bruno Larsen <blarsen@redhat.com>

Cheers,
Bruno

> ---
>   gdb/breakpoint.c | 30 +++++++++++++++---------------
>   1 file changed, 15 insertions(+), 15 deletions(-)
>
> diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
> index 002f4a935b1..6e1a15e4f1b 100644
> --- a/gdb/breakpoint.c
> +++ b/gdb/breakpoint.c
> @@ -125,11 +125,11 @@ static CORE_ADDR adjust_breakpoint_address (struct gdbarch *gdbarch,
>   					    enum bptype bptype,
>   					    struct program_space *pspace);
>   
> -static int watchpoint_locations_match (struct bp_location *loc1,
> -				       struct bp_location *loc2);
> +static int watchpoint_locations_match (const struct bp_location *loc1,
> +				       const struct bp_location *loc2);
>   
> -static int breakpoint_locations_match (struct bp_location *loc1,
> -				       struct bp_location *loc2,
> +static int breakpoint_locations_match (const struct bp_location *loc1,
> +				       const struct bp_location *loc2,
>   				       bool sw_hw_bps_match = false);
>   
>   static int breakpoint_location_address_match (struct bp_location *bl,
> @@ -2643,7 +2643,7 @@ build_target_command_list (struct bp_location *bl)
>      registers state.  */
>   
>   static int
> -breakpoint_kind (struct bp_location *bl, CORE_ADDR *addr)
> +breakpoint_kind (const struct bp_location *bl, CORE_ADDR *addr)
>   {
>     if (bl->owner->type == bp_single_step)
>       {
> @@ -4229,7 +4229,7 @@ moribund_breakpoint_here_p (const address_space *aspace, CORE_ADDR pc)
>      ASPACE.  */
>   
>   static int
> -bp_location_inserted_here_p (struct bp_location *bl,
> +bp_location_inserted_here_p (const struct bp_location *bl,
>   			     const address_space *aspace, CORE_ADDR pc)
>   {
>     if (bl->inserted
> @@ -5440,7 +5440,7 @@ bpstat_check_breakpoint_conditions (bpstat *bs, thread_info *thread)
>      on the current target.  */
>   
>   static int
> -need_moribund_for_location_type (struct bp_location *loc)
> +need_moribund_for_location_type (const struct bp_location *loc)
>   {
>     return ((loc->loc_type == bp_loc_software_breakpoint
>   	   && !target_supports_stopped_by_sw_breakpoint ())
> @@ -5974,7 +5974,7 @@ bp_condition_evaluator (const breakpoint *b)
>      similar to bp_condition_evaluator, but for locations.  */
>   
>   static const char *
> -bp_location_condition_evaluator (struct bp_location *bl)
> +bp_location_condition_evaluator (const struct bp_location *bl)
>   {
>     if (bl && !is_breakpoint (bl->owner))
>       return NULL;
> @@ -6933,8 +6933,8 @@ bl_address_is_meaningful (bp_location *loc)
>      true if LOC1 and LOC2 represent the same watchpoint location.  */
>   
>   static int
> -watchpoint_locations_match (struct bp_location *loc1,
> -			    struct bp_location *loc2)
> +watchpoint_locations_match (const struct bp_location *loc1,
> +			    const struct bp_location *loc2)
>   {
>     struct watchpoint *w1 = (struct watchpoint *) loc1->owner;
>     struct watchpoint *w2 = (struct watchpoint *) loc2->owner;
> @@ -7045,8 +7045,8 @@ breakpoint_location_address_range_overlap (struct bp_location *bl,
>      true, otherwise returns false.  */
>   
>   static int
> -tracepoint_locations_match (struct bp_location *loc1,
> -			    struct bp_location *loc2)
> +tracepoint_locations_match (const struct bp_location *loc1,
> +			    const struct bp_location *loc2)
>   {
>     if (is_tracepoint (loc1->owner) && is_tracepoint (loc2->owner))
>       /* Since tracepoint locations are never duplicated with others', tracepoint
> @@ -7064,8 +7064,8 @@ tracepoint_locations_match (struct bp_location *loc1,
>      otherwise they don't.  */
>   
>   static int
> -breakpoint_locations_match (struct bp_location *loc1,
> -			    struct bp_location *loc2,
> +breakpoint_locations_match (const struct bp_location *loc1,
> +			    const struct bp_location *loc2,
>   			    bool sw_hw_bps_match)
>   {
>     int hw_point1, hw_point2;
> @@ -13157,7 +13157,7 @@ enable_disable_bp_num_loc (int bp_num, int loc_num, bool enable)
>      owner.  1-based indexing.  -1 signals NOT FOUND.  */
>   
>   static int
> -find_loc_num_by_location (bp_location *loc)
> +find_loc_num_by_location (const bp_location *loc)
>   {
>     if (loc != nullptr && loc->owner != nullptr)
>       {
  

Patch

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 002f4a935b1..6e1a15e4f1b 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -125,11 +125,11 @@  static CORE_ADDR adjust_breakpoint_address (struct gdbarch *gdbarch,
 					    enum bptype bptype,
 					    struct program_space *pspace);
 
-static int watchpoint_locations_match (struct bp_location *loc1,
-				       struct bp_location *loc2);
+static int watchpoint_locations_match (const struct bp_location *loc1,
+				       const struct bp_location *loc2);
 
-static int breakpoint_locations_match (struct bp_location *loc1,
-				       struct bp_location *loc2,
+static int breakpoint_locations_match (const struct bp_location *loc1,
+				       const struct bp_location *loc2,
 				       bool sw_hw_bps_match = false);
 
 static int breakpoint_location_address_match (struct bp_location *bl,
@@ -2643,7 +2643,7 @@  build_target_command_list (struct bp_location *bl)
    registers state.  */
 
 static int
-breakpoint_kind (struct bp_location *bl, CORE_ADDR *addr)
+breakpoint_kind (const struct bp_location *bl, CORE_ADDR *addr)
 {
   if (bl->owner->type == bp_single_step)
     {
@@ -4229,7 +4229,7 @@  moribund_breakpoint_here_p (const address_space *aspace, CORE_ADDR pc)
    ASPACE.  */
 
 static int
-bp_location_inserted_here_p (struct bp_location *bl,
+bp_location_inserted_here_p (const struct bp_location *bl,
 			     const address_space *aspace, CORE_ADDR pc)
 {
   if (bl->inserted
@@ -5440,7 +5440,7 @@  bpstat_check_breakpoint_conditions (bpstat *bs, thread_info *thread)
    on the current target.  */
 
 static int
-need_moribund_for_location_type (struct bp_location *loc)
+need_moribund_for_location_type (const struct bp_location *loc)
 {
   return ((loc->loc_type == bp_loc_software_breakpoint
 	   && !target_supports_stopped_by_sw_breakpoint ())
@@ -5974,7 +5974,7 @@  bp_condition_evaluator (const breakpoint *b)
    similar to bp_condition_evaluator, but for locations.  */
 
 static const char *
-bp_location_condition_evaluator (struct bp_location *bl)
+bp_location_condition_evaluator (const struct bp_location *bl)
 {
   if (bl && !is_breakpoint (bl->owner))
     return NULL;
@@ -6933,8 +6933,8 @@  bl_address_is_meaningful (bp_location *loc)
    true if LOC1 and LOC2 represent the same watchpoint location.  */
 
 static int
-watchpoint_locations_match (struct bp_location *loc1, 
-			    struct bp_location *loc2)
+watchpoint_locations_match (const struct bp_location *loc1,
+			    const struct bp_location *loc2)
 {
   struct watchpoint *w1 = (struct watchpoint *) loc1->owner;
   struct watchpoint *w2 = (struct watchpoint *) loc2->owner;
@@ -7045,8 +7045,8 @@  breakpoint_location_address_range_overlap (struct bp_location *bl,
    true, otherwise returns false.  */
 
 static int
-tracepoint_locations_match (struct bp_location *loc1,
-			    struct bp_location *loc2)
+tracepoint_locations_match (const struct bp_location *loc1,
+			    const struct bp_location *loc2)
 {
   if (is_tracepoint (loc1->owner) && is_tracepoint (loc2->owner))
     /* Since tracepoint locations are never duplicated with others', tracepoint
@@ -7064,8 +7064,8 @@  tracepoint_locations_match (struct bp_location *loc1,
    otherwise they don't.  */
 
 static int
-breakpoint_locations_match (struct bp_location *loc1,
-			    struct bp_location *loc2,
+breakpoint_locations_match (const struct bp_location *loc1,
+			    const struct bp_location *loc2,
 			    bool sw_hw_bps_match)
 {
   int hw_point1, hw_point2;
@@ -13157,7 +13157,7 @@  enable_disable_bp_num_loc (int bp_num, int loc_num, bool enable)
    owner.  1-based indexing.  -1 signals NOT FOUND.  */
 
 static int
-find_loc_num_by_location (bp_location *loc)
+find_loc_num_by_location (const bp_location *loc)
 {
   if (loc != nullptr && loc->owner != nullptr)
     {