[01/12] gdb: get gdbarch from syscall_catchpoint instead of location

Message ID 20230511144832.17974-2-simon.marchi@efficios.com
State New
Headers
Series Use intrusive_list for breakpoints and breakpoint locations |

Commit Message

Simon Marchi May 11, 2023, 2:48 p.m. UTC
  I noticed some methods of syscall_catchpoint doing this:

  struct gdbarch *gdbarch = loc->owner->gdbarch;

`loc` is the list of locations of this catchpoint.  Logically, the owner
the locations are this catchpoint.  So this just ends up getting
this->gdbarch.  Remove the unnecessary indirection through the loc.

syscall_catchpoint::print_recreate does something slightly different,
getting its arch from the loc:

  struct gdbarch *gdbarch = loc->gdbarch;

I suppose it's always going to be the same arch, so get it from the
catchpoint there too.

Change-Id: I6f6a6f8e0cd7cfb754cecfb6249e71ec12ba4855
---
 gdb/break-catch-syscall.c | 6 ------
 1 file changed, 6 deletions(-)
  

Comments

Alexandra Hájková May 15, 2023, 9:12 a.m. UTC | #1
On Thu, May 11, 2023 at 4:48 PM Simon Marchi via Gdb-patches <
gdb-patches@sourceware.org> wrote:

> I noticed some methods of syscall_catchpoint doing this:
>
>   struct gdbarch *gdbarch = loc->owner->gdbarch;
>
> `loc` is the list of locations of this catchpoint.  Logically, the owner
> the locations are this catchpoint.  So this just ends up getting
> this->gdbarch.  Remove the unnecessary indirection through the loc.
>
> syscall_catchpoint::print_recreate does something slightly different,
> getting its arch from the loc:
>
>   struct gdbarch *gdbarch = loc->gdbarch;
>
> I suppose it's always going to be the same arch, so get it from the
> catchpoint there too.
>
> Change-Id: I6f6a6f8e0cd7cfb754cecfb6249e71ec12ba4855
> ---
>  gdb/break-catch-syscall.c | 6 ------
>  1 file changed, 6 deletions(-)
>
>
> This change seems to be reasonable and I can confirm it causes no
regression on aarch64 with Fedora-Rawhide.
  

Patch

diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c
index d73f6616c97a..595b05c90c8e 100644
--- a/gdb/break-catch-syscall.c
+++ b/gdb/break-catch-syscall.c
@@ -197,7 +197,6 @@  syscall_catchpoint::print_it (const bpstat *bs) const
      must print "called syscall" or "returned from syscall".  */
   struct target_waitstatus last;
   struct syscall s;
-  struct gdbarch *gdbarch = b->gdbarch;
 
   get_last_target_status (nullptr, nullptr, &last);
 
@@ -242,7 +241,6 @@  syscall_catchpoint::print_one (bp_location **last_loc) const
 {
   struct value_print_options opts;
   struct ui_out *uiout = current_uiout;
-  struct gdbarch *gdbarch = loc->owner->gdbarch;
 
   get_user_print_options (&opts);
   /* Field 4, the address, is omitted (which makes the columns not
@@ -293,8 +291,6 @@  syscall_catchpoint::print_one (bp_location **last_loc) const
 void
 syscall_catchpoint::print_mention () const
 {
-  struct gdbarch *gdbarch = loc->owner->gdbarch;
-
   if (!syscalls_to_be_caught.empty ())
     {
       if (syscalls_to_be_caught.size () > 1)
@@ -323,8 +319,6 @@  syscall_catchpoint::print_mention () const
 void
 syscall_catchpoint::print_recreate (struct ui_file *fp) const
 {
-  struct gdbarch *gdbarch = loc->gdbarch;
-
   gdb_printf (fp, "catch syscall");
 
   for (int iter : syscalls_to_be_caught)