[PATCH 1/2] gdb/testsuite: move get_maint_bp_addr to gdb-utils.exp
Enze Li
enze.li@hotmail.com
Thu Jun 23 13:12:16 GMT 2022
Hi Andrew,
Thanks for your review.
Naming is a hard thing for me. gdb_get_bp_addr seems to have more
features than before, and starting with 'gdb' looks good. 🙂
V2 of this patch is on the way.
Best Regards,
Enze
On Tue, 2022-06-21 at 17:12 +0100, Andrew Burgess wrote:
> Enze Li via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> > The get_maint_bp_addr procedure will be shared by other test suite,
> > so
> > move it to gdb-utils.exp.
> > ---
> > gdb/testsuite/gdb.base/clear_non_user_bp.exp | 23 ----------------
> > ----
> > gdb/testsuite/lib/gdb-utils.exp | 23
> > ++++++++++++++++++++
> > 2 files changed, 23 insertions(+), 23 deletions(-)
> >
> > diff --git a/gdb/testsuite/gdb.base/clear_non_user_bp.exp
> > b/gdb/testsuite/gdb.base/clear_non_user_bp.exp
> > index 26d7a31fa47..399a3a0f0dc 100644
> > --- a/gdb/testsuite/gdb.base/clear_non_user_bp.exp
> > +++ b/gdb/testsuite/gdb.base/clear_non_user_bp.exp
> > @@ -16,29 +16,6 @@
> > # Regression test for PR gdb/7161. Test that GDB cannot delete
> > non-user
> > # breakpoints with clear command.
> >
> > -# get_maint_bp_addr num
> > -#
> > -# Purpose:
> > -# Get address of the specified internal breakpoint when using
> > command
> > -# "maint info breakpoints $num".
> > -#
> > -# Parameter:
> > -# The parameter "num" indicates the number of the internal
> > breakpoint
> > -# to get. Note that this parameter must be a negative number.
> > -# E.g., -1 means that we're gonna get the first internal
> > breakpoint.
> > -#
> > -# Return:
> > -# Internal breakpoint address.
> > -#
> > -proc get_maint_bp_addr { num } {
> > - gdb_test_multiple "maint info break $num" "find address of
> > internal bp $num" {
> > - -re -wrap ".*(0x\[0-9a-f\]+).*" {
> > - return $expect_out(1,string)
> > - }
> > - }
> > - return ""
> > -}
> > -
> > # get_first_maint_bp_num
> > #
> > # Purpose:
> > diff --git a/gdb/testsuite/lib/gdb-utils.exp
> > b/gdb/testsuite/lib/gdb-utils.exp
> > index ffdfb75557c..bf2863722ce 100644
> > --- a/gdb/testsuite/lib/gdb-utils.exp
> > +++ b/gdb/testsuite/lib/gdb-utils.exp
> > @@ -72,3 +72,26 @@ proc style {str style} {
> > }
> > return "\033\\\[${style}m${str}\033\\\[m"
> > }
> > +
> > +# get_maint_bp_addr num
> > +#
> > +# Purpose:
> > +# Get address of the specified internal breakpoint when using
> > command
> > +# "maint info breakpoints $num".
> > +#
> > +# Parameter:
> > +# The parameter "num" indicates the number of the internal
> > breakpoint
> > +# to get. Note that this parameter must be a negative number.
> > +# E.g., -1 means that we're gonna get the first internal
> > breakpoint.
> > +#
> > +# Return:
> > +# Internal breakpoint address.
> > +#
> > +proc get_maint_bp_addr { num } {
> > + gdb_test_multiple "maint info break $num" "find address of
> > internal bp $num" {
> > + -re -wrap ".*(0x\[0-9a-f\]+).*" {
> > + return $expect_out(1,string)
> > + }
> > + }
> > + return ""
> > +}
>
> Before the get_maint_bp_addr name gets spread around too much, I
> think
> we should rename this. I'd propose maybe gdb_get_bp_addr. The
> comment
> should be reworked to remove the mention of negative values, as I
> believe this function will work just as well with positive values.
>
> I think the comment should also be expanded to indicate that
> (currently)
> this function will only take integer values for NUM, and will return
> the
> first address for a particular breakpoint, e.g. we can't say
> 'get_maint_bp_addr 1.2' to get the address of the second location of
> breakpoint #1.
>
> I don't think that we need to make the actual implementation of
> get_maint_bp_addr better right now, but if we give the function a
> good
> name, and explain the limitations in the comments, then, if we ever
> need
> to, we can improve the function later.
>
> Thanks,
> Andrew
>
> > --
> > 2.36.1
>
More information about the Gdb-patches
mailing list