From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 02/12] gdb: make some breakpoint methods use `this`
Date: Thu, 11 May 2023 10:48:22 -0400 [thread overview]
Message-ID: <20230511144832.17974-3-simon.marchi@efficios.com> (raw)
In-Reply-To: <20230511144832.17974-1-simon.marchi@efficios.com>
Some implementations of breakpoint::check_status and
breakpoint::print_it do this:
struct breakpoint *b = bs->breakpoint_at;
bs->breakpoint_at is always the same as `this` (we can get convinced by
looking at the call sites of check_status and print_it), so it would
just be clearer to access fields through `this` instead.
Change-Id: Ic542a64fcd88e31ae2aad6feff1da278c7086891
---
gdb/break-catch-load.c | 9 ++++-----
gdb/break-catch-syscall.c | 7 +++----
gdb/break-catch-throw.c | 6 ++----
gdb/breakpoint.c | 26 ++++++++++----------------
4 files changed, 19 insertions(+), 29 deletions(-)
diff --git a/gdb/break-catch-load.c b/gdb/break-catch-load.c
index d8dab0bd091b..e01f6450fd76 100644
--- a/gdb/break-catch-load.c
+++ b/gdb/break-catch-load.c
@@ -141,19 +141,18 @@ solib_catchpoint::check_status (struct bpstat *bs)
enum print_stop_action
solib_catchpoint::print_it (const bpstat *bs) const
{
- struct breakpoint *b = bs->breakpoint_at;
struct ui_out *uiout = current_uiout;
- annotate_catchpoint (b->number);
+ annotate_catchpoint (this->number);
maybe_print_thread_hit_breakpoint (uiout);
- if (b->disposition == disp_del)
+ if (this->disposition == disp_del)
uiout->text ("Temporary catchpoint ");
else
uiout->text ("Catchpoint ");
- uiout->field_signed ("bkptno", b->number);
+ uiout->field_signed ("bkptno", this->number);
uiout->text ("\n");
if (uiout->is_mi_like_p ())
- uiout->field_string ("disp", bpdisp_text (b->disposition));
+ uiout->field_string ("disp", bpdisp_text (this->disposition));
print_solib_event (true);
return PRINT_SRC_AND_LOC;
}
diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c
index 595b05c90c8e..6475f4aa172a 100644
--- a/gdb/break-catch-syscall.c
+++ b/gdb/break-catch-syscall.c
@@ -190,7 +190,6 @@ enum print_stop_action
syscall_catchpoint::print_it (const bpstat *bs) const
{
struct ui_out *uiout = current_uiout;
- struct breakpoint *b = bs->breakpoint_at;
/* These are needed because we want to know in which state a
syscall is. It can be in the TARGET_WAITKIND_SYSCALL_ENTRY
or TARGET_WAITKIND_SYSCALL_RETURN, and depending on it we
@@ -202,10 +201,10 @@ syscall_catchpoint::print_it (const bpstat *bs) const
get_syscall_by_number (gdbarch, last.syscall_number (), &s);
- annotate_catchpoint (b->number);
+ annotate_catchpoint (this->number);
maybe_print_thread_hit_breakpoint (uiout);
- if (b->disposition == disp_del)
+ if (this->disposition == disp_del)
uiout->text ("Temporary catchpoint ");
else
uiout->text ("Catchpoint ");
@@ -215,7 +214,7 @@ syscall_catchpoint::print_it (const bpstat *bs) const
async_reason_lookup (last.kind () == TARGET_WAITKIND_SYSCALL_ENTRY
? EXEC_ASYNC_SYSCALL_ENTRY
: EXEC_ASYNC_SYSCALL_RETURN));
- uiout->field_string ("disp", bpdisp_text (b->disposition));
+ uiout->field_string ("disp", bpdisp_text (this->disposition));
}
print_num_locno (bs, uiout);
diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
index 457446efbc6e..604c1855c0de 100644
--- a/gdb/break-catch-throw.c
+++ b/gdb/break-catch-throw.c
@@ -160,15 +160,13 @@ fetch_probe_arguments (struct value **arg0, struct value **arg1)
void
exception_catchpoint::check_status (struct bpstat *bs)
{
- struct exception_catchpoint *self
- = (struct exception_catchpoint *) bs->breakpoint_at;
std::string type_name;
this->breakpoint::check_status (bs);
if (!bs->stop)
return;
- if (self->pattern == NULL)
+ if (this->pattern == NULL)
return;
const char *name = nullptr;
@@ -192,7 +190,7 @@ exception_catchpoint::check_status (struct bpstat *bs)
if (name != nullptr)
{
- if (self->pattern->exec (name, 0, NULL, 0) != 0)
+ if (this->pattern->exec (name, 0, NULL, 0) != 0)
bs->stop = false;
}
}
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index dcb00bffdbe8..1fdd5c3767f9 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -9699,8 +9699,6 @@ watchpoint::breakpoint_hit (const struct bp_location *bl,
void
watchpoint::check_status (bpstat *bs)
{
- gdb_assert (is_watchpoint (bs->breakpoint_at));
-
bpstat_check_watchpoint (bs);
}
@@ -9728,28 +9726,25 @@ watchpoint::works_in_software_mode () const
enum print_stop_action
watchpoint::print_it (const bpstat *bs) const
{
- struct breakpoint *b;
enum print_stop_action result;
struct ui_out *uiout = current_uiout;
gdb_assert (bs->bp_location_at != NULL);
- b = bs->breakpoint_at;
-
- annotate_watchpoint (b->number);
+ annotate_watchpoint (this->number);
maybe_print_thread_hit_breakpoint (uiout);
string_file stb;
gdb::optional<ui_out_emit_tuple> tuple_emitter;
- switch (b->type)
+ switch (this->type)
{
case bp_watchpoint:
case bp_hardware_watchpoint:
if (uiout->is_mi_like_p ())
uiout->field_string
("reason", async_reason_lookup (EXEC_ASYNC_WATCHPOINT_TRIGGER));
- mention (b);
+ mention (this);
tuple_emitter.emplace (uiout, "value");
uiout->text ("\nOld value = ");
watchpoint_value_print (bs->old_val.get (), &stb);
@@ -9766,7 +9761,7 @@ watchpoint::print_it (const bpstat *bs) const
if (uiout->is_mi_like_p ())
uiout->field_string
("reason", async_reason_lookup (EXEC_ASYNC_READ_WATCHPOINT_TRIGGER));
- mention (b);
+ mention (this);
tuple_emitter.emplace (uiout, "value");
uiout->text ("\nValue = ");
watchpoint_value_print (val.get (), &stb);
@@ -9782,7 +9777,7 @@ watchpoint::print_it (const bpstat *bs) const
uiout->field_string
("reason",
async_reason_lookup (EXEC_ASYNC_ACCESS_WATCHPOINT_TRIGGER));
- mention (b);
+ mention (this);
tuple_emitter.emplace (uiout, "value");
uiout->text ("\nOld value = ");
watchpoint_value_print (bs->old_val.get (), &stb);
@@ -9791,7 +9786,7 @@ watchpoint::print_it (const bpstat *bs) const
}
else
{
- mention (b);
+ mention (this);
if (uiout->is_mi_like_p ())
uiout->field_string
("reason",
@@ -9943,16 +9938,15 @@ masked_watchpoint::works_in_software_mode () const
enum print_stop_action
masked_watchpoint::print_it (const bpstat *bs) const
{
- struct breakpoint *b = bs->breakpoint_at;
struct ui_out *uiout = current_uiout;
/* Masked watchpoints have only one location. */
- gdb_assert (b->loc && b->loc->next == NULL);
+ gdb_assert (this->loc && this->loc->next == nullptr);
- annotate_watchpoint (b->number);
+ annotate_watchpoint (this->number);
maybe_print_thread_hit_breakpoint (uiout);
- switch (b->type)
+ switch (this->type)
{
case bp_hardware_watchpoint:
if (uiout->is_mi_like_p ())
@@ -9976,7 +9970,7 @@ masked_watchpoint::print_it (const bpstat *bs) const
internal_error (_("Invalid hardware watchpoint type."));
}
- mention (b);
+ mention (this);
uiout->text (_("\n\
Check the underlying instruction at PC for the memory\n\
address and value which triggered this watchpoint.\n"));
--
2.40.1
next prev parent reply other threads:[~2023-05-11 14:48 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-11 14:48 [PATCH 00/12] Use intrusive_list for breakpoints and breakpoint locations Simon Marchi
2023-05-11 14:48 ` [PATCH 01/12] gdb: get gdbarch from syscall_catchpoint instead of location Simon Marchi
2023-05-15 9:12 ` Alexandra Petlanova Hajkova
2023-05-11 14:48 ` Simon Marchi [this message]
2023-05-15 13:12 ` [PATCH 02/12] gdb: make some breakpoint methods use `this` Alexandra Petlanova Hajkova
2023-05-15 18:25 ` Simon Marchi
2023-05-11 14:48 ` [PATCH 03/12] gdb: constify breakpoint::print_it parameter Simon Marchi
2023-05-11 14:48 ` [PATCH 04/12] gdb: add breakpoint "has locations" methods Simon Marchi
2023-05-11 14:48 ` [PATCH 05/12] gdb: add breakpoint::first_loc methods Simon Marchi
2023-05-18 12:50 ` Andrew Burgess
2023-05-18 17:55 ` Simon Marchi
2023-05-24 13:00 ` Andrew Burgess
2023-05-11 14:48 ` [PATCH 06/12] gdbsupport: add missing increment/decrement operators to reference_to_pointer_iterator Simon Marchi
2023-05-11 14:48 ` [PATCH 07/12] gdb: link breakpoint locations with intrusive_list Simon Marchi
2023-05-18 14:44 ` Andrew Burgess
2023-05-18 18:40 ` Simon Marchi
2023-05-24 13:04 ` Andrew Burgess
2023-05-11 14:48 ` [PATCH 08/12] gdb: remove bp_location_pointer_iterator Simon Marchi
2023-05-11 14:48 ` [PATCH 09/12] gdb: link breakpoints with intrusive_list Simon Marchi
2023-05-11 14:48 ` [PATCH 10/12] gdbsupport: make basic_safe_iterator::operator* return the same thing as underlying iterator Simon Marchi
2023-05-11 14:48 ` [PATCH 11/12] gdbsupport: make filtered_iterator::operator* " Simon Marchi
2023-05-11 14:48 ` [PATCH 12/12] gdb: remove breakpoint_pointer_iterator Simon Marchi
2023-05-18 15:53 ` Andrew Burgess
2023-05-18 18:44 ` Simon Marchi
2023-05-18 20:59 ` Simon Marchi
2023-05-18 15:54 ` [PATCH 00/12] Use intrusive_list for breakpoints and breakpoint locations Andrew Burgess
2023-05-18 21:01 ` Simon Marchi
2023-05-25 14:01 ` Simon Marchi
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=20230511144832.17974-3-simon.marchi@efficios.com \
--to=simon.marchi@efficios.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).