From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1551) id 6DA2C3856DEA; Fri, 20 May 2022 19:42:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6DA2C3856DEA Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Pedro Alves To: gdb-cvs@sourceware.org Subject: [binutils-gdb] add_location_to_breakpoint -> breakpoint::add_location X-Act-Checkin: binutils-gdb X-Git-Author: Pedro Alves X-Git-Refname: refs/heads/master X-Git-Oldrev: f9a8785566fcd9b36f8e504346f70bc3d5b6cf82 X-Git-Newrev: 06615628294ceb515c045050a39cff4d66a20c1e Message-Id: <20220520194228.6DA2C3856DEA@sourceware.org> Date: Fri, 20 May 2022 19:42:28 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 May 2022 19:42:28 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D06615628294c= eb515c045050a39cff4d66a20c1e commit 06615628294ceb515c045050a39cff4d66a20c1e Author: Pedro Alves Date: Fri May 6 19:18:48 2022 +0100 add_location_to_breakpoint -> breakpoint::add_location =20 Make add_location_to_breakpoint be a method of struct breakpoint. =20 A patch later in the series will move this to base_breakpoint, but for now, it needs to be here. =20 Change-Id: I5bdc2ec1a7c2d66f26f51bf6f6adc8384a90b129 Diff: --- gdb/breakpoint.c | 70 ++++++++++++++++++++++++++--------------------------= ---- gdb/breakpoint.h | 3 +++ 2 files changed, 36 insertions(+), 37 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 9abc1443d96..385c92a6e7b 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -114,9 +114,6 @@ static void mention (const breakpoint *); =20 static struct breakpoint *set_raw_breakpoint_without_location (struct gdba= rch *, enum bptype); -static struct bp_location *add_location_to_breakpoint (struct breakpoint *, - const struct symtab_and_line *); - /* This function is used in gdbtk sources and thus can not be made static. */ static struct breakpoint *set_raw_breakpoint (struct gdbarch *gdbarch, @@ -7308,7 +7305,7 @@ static void init_raw_breakpoint (struct breakpoint *b, struct symtab_and_line sal, enum bptype bptype) { - add_location_to_breakpoint (b, &sal); + b->add_location (sal); =20 if (bptype !=3D bp_catchpoint) gdb_assert (sal.pspace !=3D NULL); @@ -8109,16 +8106,15 @@ handle_automatic_hardware_breakpoints (bp_location = *bl) } } =20 -static struct bp_location * -add_location_to_breakpoint (struct breakpoint *b, - const struct symtab_and_line *sal) +bp_location * +breakpoint::add_location (const symtab_and_line &sal) { - struct bp_location *loc, **tmp; + struct bp_location *new_loc, **tmp; CORE_ADDR adjusted_address; - struct gdbarch *loc_gdbarch =3D get_sal_arch (*sal); + struct gdbarch *loc_gdbarch =3D get_sal_arch (sal); =20 if (loc_gdbarch =3D=3D NULL) - loc_gdbarch =3D b->gdbarch; + loc_gdbarch =3D gdbarch; =20 /* Adjust the breakpoint's address prior to allocating a location. Once we call allocate_location(), that mostly uninitialized @@ -8127,31 +8123,31 @@ add_location_to_breakpoint (struct breakpoint *b, not want its scan of the location chain to find a breakpoint and location that's only been partially initialized. */ adjusted_address =3D adjust_breakpoint_address (loc_gdbarch, - sal->pc, b->type); + sal.pc, type); =20 /* Sort the locations by their ADDRESS. */ - loc =3D b->allocate_location (); - for (tmp =3D &(b->loc); *tmp !=3D NULL && (*tmp)->address <=3D adjusted_= address; + new_loc =3D allocate_location (); + for (tmp =3D &(loc); *tmp !=3D NULL && (*tmp)->address <=3D adjusted_add= ress; tmp =3D &((*tmp)->next)) ; - loc->next =3D *tmp; - *tmp =3D loc; - - loc->requested_address =3D sal->pc; - loc->address =3D adjusted_address; - loc->pspace =3D sal->pspace; - loc->probe.prob =3D sal->prob; - loc->probe.objfile =3D sal->objfile; - gdb_assert (loc->pspace !=3D NULL); - loc->section =3D sal->section; - loc->gdbarch =3D loc_gdbarch; - loc->line_number =3D sal->line; - loc->symtab =3D sal->symtab; - loc->symbol =3D sal->symbol; - loc->msymbol =3D sal->msymbol; - loc->objfile =3D sal->objfile; - - set_breakpoint_location_function (loc); + new_loc->next =3D *tmp; + *tmp =3D new_loc; + + new_loc->requested_address =3D sal.pc; + new_loc->address =3D adjusted_address; + new_loc->pspace =3D sal.pspace; + new_loc->probe.prob =3D sal.prob; + new_loc->probe.objfile =3D sal.objfile; + gdb_assert (new_loc->pspace !=3D NULL); + new_loc->section =3D sal.section; + new_loc->gdbarch =3D loc_gdbarch; + new_loc->line_number =3D sal.line; + new_loc->symtab =3D sal.symtab; + new_loc->symbol =3D sal.symbol; + new_loc->msymbol =3D sal.msymbol; + new_loc->objfile =3D sal.objfile; + + set_breakpoint_location_function (new_loc); =20 /* While by definition, permanent breakpoints are already present in the code, we don't mark the location as inserted. Normally one would exp= ect @@ -8166,10 +8162,10 @@ add_location_to_breakpoint (struct breakpoint *b, (If GDB later needs to continue execution past the permanent breakpoi= nt, it manually increments the PC, thus avoiding executing the breakpoint instruction.) */ - if (bp_loc_is_permanent (loc)) - loc->permanent =3D 1; + if (bp_loc_is_permanent (new_loc)) + new_loc->permanent =3D 1; =20 - return loc; + return new_loc; } =0C =20 @@ -8375,7 +8371,7 @@ init_breakpoint_sal (struct breakpoint *b, struct gdb= arch *gdbarch, } else { - loc =3D add_location_to_breakpoint (b, &sal); + loc =3D b->add_location (sal); if ((flags & CREATE_BREAKPOINT_FLAGS_INSERTED) !=3D 0) loc->inserted =3D 1; } @@ -12646,7 +12642,7 @@ update_breakpoint_locations (struct breakpoint *b, =20 switch_to_program_space_and_thread (sal.pspace); =20 - new_loc =3D add_location_to_breakpoint (b, &sal); + new_loc =3D b->add_location (sal); =20 /* Reparse conditions, they might contain references to the old symtab. */ @@ -13537,7 +13533,7 @@ insert_single_step_breakpoint (struct gdbarch *gdba= rch, sal.pc =3D pc; sal.section =3D find_pc_overlay (pc); sal.explicit_pc =3D 1; - add_location_to_breakpoint (tp->control.single_step_breakpoints, &sal); + tp->control.single_step_breakpoints->add_location (sal); =20 update_global_location_list (UGLL_INSERT); } diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index ac738fd7c2d..fb8651c55c3 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -739,6 +739,9 @@ struct breakpoint /* Nothing to do. */ } =20 + /* Add a location for SAL to this breakpoint. */ + bp_location *add_location (const symtab_and_line &sal); + /* Return a range of this breakpoint's locations. */ bp_location_range locations () const;