[v2,2/3] Use gdbarch for probe::get_argument_count

Message ID 20190821155816.45504-3-alan.hayward@arm.com
State New, archived
Headers

Commit Message

Alan Hayward Aug. 21, 2019, 3:58 p.m. UTC
  The probe function get_argument_count does not need a frame, only
the current gdbarch.  Switch the code to pass gdbarch instead.
No functional changes.

gdb/ChangeLog:

2019-08-21  Alan Hayward  <alan.hayward@arm.com>

	* break-catch-throw.c (fetch_probe_arguments): Use gdbarch.
	* dtrace-probe.c (dtrace_probe::get_argument_count): Likewise.
	* probe.c (probe_safe_evaluate_at_pc) (compute_probe_arg)
	(compile_probe_arg): Likewise.
	* probe.h (get_argument_count): Likewise.
	* solib-svr4.c (solib_event_probe_action): Likewise.
	* stap-probe.c (stap_probe::get_argument_count): Likewise.
---
 gdb/break-catch-throw.c | 2 +-
 gdb/dtrace-probe.c      | 4 ++--
 gdb/probe.c             | 7 +++----
 gdb/probe.h             | 2 +-
 gdb/solib-svr4.c        | 2 +-
 gdb/stap-probe.c        | 6 ++----
 6 files changed, 10 insertions(+), 13 deletions(-)
  

Comments

Sergio Durigan Junior Sept. 4, 2019, 5:58 p.m. UTC | #1
On Wednesday, August 21 2019, Alan Hayward wrote:

> The probe function get_argument_count does not need a frame, only
> the current gdbarch.  Switch the code to pass gdbarch instead.
> No functional changes.

The patch looks good at first glance, but I'd like to apply it before
approving.  Unfortunately, it seems like your MUA has mangled the
message (which is strange, because apparently you're using
git-send-email):

  <https://sourceware.org/cgi-bin/get-raw-msg?listname=gdb-patches&date=2019-08&msgid=20190821155816.45504-3-alan.hayward%40arm.com>

Can you resend it, please?

> gdb/ChangeLog:
>
> 2019-08-21  Alan Hayward  <alan.hayward@arm.com>
>
> 	* break-catch-throw.c (fetch_probe_arguments): Use gdbarch.
> 	* dtrace-probe.c (dtrace_probe::get_argument_count): Likewise.
> 	* probe.c (probe_safe_evaluate_at_pc) (compute_probe_arg)
> 	(compile_probe_arg): Likewise.
> 	* probe.h (get_argument_count): Likewise.
> 	* solib-svr4.c (solib_event_probe_action): Likewise.
> 	* stap-probe.c (stap_probe::get_argument_count): Likewise.
> ---
>  gdb/break-catch-throw.c | 2 +-
>  gdb/dtrace-probe.c      | 4 ++--
>  gdb/probe.c             | 7 +++----
>  gdb/probe.h             | 2 +-
>  gdb/solib-svr4.c        | 2 +-
>  gdb/stap-probe.c        | 6 ++----
>  6 files changed, 10 insertions(+), 13 deletions(-)
>
> diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
> index 0677a55ee5..2c2a3b7d72 100644
> --- a/gdb/break-catch-throw.c
> +++ b/gdb/break-catch-throw.c
> @@ -113,7 +113,7 @@ fetch_probe_arguments (struct value **arg0, struct value **arg1)
>  	  && pc_probe.prob->get_name () != "rethrow"))
>      error (_("not stopped at a C++ exception catchpoint"));
>  
> -  n_args = pc_probe.prob->get_argument_count (frame);
> +  n_args = pc_probe.prob->get_argument_count (get_frame_arch (frame));
>    if (n_args < 2)
>      error (_("C++ exception catchpoint has too few arguments"));
>  
> diff --git a/gdb/dtrace-probe.c b/gdb/dtrace-probe.c
> index 2d92edb11c..e9e71fd4c9 100644
> --- a/gdb/dtrace-probe.c
> +++ b/gdb/dtrace-probe.c
> @@ -122,7 +122,7 @@ public:
>    CORE_ADDR get_relocated_address (struct objfile *objfile) override;
>  
>    /* See probe.h.  */
> -  unsigned get_argument_count (struct frame_info *frame) override;
> +  unsigned get_argument_count (struct gdbarch *gdbarch) override;
>  
>    /* See probe.h.  */
>    bool can_evaluate_arguments () const override;
> @@ -693,7 +693,7 @@ dtrace_probe::get_relocated_address (struct objfile *objfile)
>  /* Implementation of the get_argument_count method.  */
>  
>  unsigned
> -dtrace_probe::get_argument_count (struct frame_info *frame)
> +dtrace_probe::get_argument_count (struct gdbarch *gdbarch)
>  {
>    return m_args.size ();
>  }
> diff --git a/gdb/probe.c b/gdb/probe.c
> index cdc6e021d2..8b108d6b02 100644
> --- a/gdb/probe.c
> +++ b/gdb/probe.c
> @@ -695,7 +695,7 @@ probe_safe_evaluate_at_pc (struct frame_info *frame, unsigned n)
>    if (!probe.prob)
>      return NULL;
>  
> -  n_args = probe.prob->get_argument_count (frame);
> +  n_args = probe.prob->get_argument_count (get_frame_arch (frame));
>    if (n >= n_args)
>      return NULL;
>  
> @@ -818,7 +818,7 @@ compute_probe_arg (struct gdbarch *arch, struct internalvar *ivar,
>    if (pc_probe.prob == NULL)
>      error (_("No probe at PC %s"), core_addr_to_string (pc));
>  
> -  n_args = pc_probe.prob->get_argument_count (frame);
> +  n_args = pc_probe.prob->get_argument_count (arch);
>    if (sel == -1)
>      return value_from_longest (builtin_type (arch)->builtin_int, n_args);
>  
> @@ -840,7 +840,6 @@ compile_probe_arg (struct internalvar *ivar, struct agent_expr *expr,
>    int sel = (int) (uintptr_t) data;
>    struct bound_probe pc_probe;
>    int n_args;
> -  struct frame_info *frame = get_selected_frame (NULL);
>  
>    /* SEL == -1 means "_probe_argc".  */
>    gdb_assert (sel >= -1);
> @@ -849,7 +848,7 @@ compile_probe_arg (struct internalvar *ivar, struct agent_expr *expr,
>    if (pc_probe.prob == NULL)
>      error (_("No probe at PC %s"), core_addr_to_string (pc));
>  
> -  n_args = pc_probe.prob->get_argument_count (frame);
> +  n_args = pc_probe.prob->get_argument_count (expr->gdbarch);
>  
>    if (sel == -1)
>      {
> diff --git a/gdb/probe.h b/gdb/probe.h
> index 8abf69e354..7410c5aadf 100644
> --- a/gdb/probe.h
> +++ b/gdb/probe.h
> @@ -131,7 +131,7 @@ public:
>  
>    /* Return the number of arguments of the probe.  This function can
>       throw an exception.  */
> -  virtual unsigned get_argument_count (struct frame_info *frame) = 0;
> +  virtual unsigned get_argument_count (struct gdbarch *gdbarch) = 0;
>  
>    /* Return 1 if the probe interface can evaluate the arguments of
>       probe, zero otherwise.  See the comments on
> diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
> index b21eacb68f..2a44dd6985 100644
> --- a/gdb/solib-svr4.c
> +++ b/gdb/solib-svr4.c
> @@ -1756,7 +1756,7 @@ solib_event_probe_action (struct probe_and_action *pa)
>         arg2: struct link_map *new (optional, for incremental updates)  */
>    try
>      {
> -      probe_argc = pa->prob->get_argument_count (frame);
> +      probe_argc = pa->prob->get_argument_count (get_frame_arch (frame));
>      }
>    catch (const gdb_exception_error &ex)
>      {
> diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c
> index b6de873d2c..700b657967 100644
> --- a/gdb/stap-probe.c
> +++ b/gdb/stap-probe.c
> @@ -136,7 +136,7 @@ public:
>    CORE_ADDR get_relocated_address (struct objfile *objfile) override;
>  
>    /* See probe.h.  */
> -  unsigned get_argument_count (struct frame_info *frame) override;
> +  unsigned get_argument_count (struct gdbarch *gdbarch) override;
>  
>    /* See probe.h.  */
>    bool can_evaluate_arguments () const override;
> @@ -1301,10 +1301,8 @@ stap_probe::get_relocated_address (struct objfile *objfile)
>     argument string.  */
>  
>  unsigned
> -stap_probe::get_argument_count (struct frame_info *frame)
> +stap_probe::get_argument_count (struct gdbarch *gdbarch)
>  {
> -  struct gdbarch *gdbarch = get_frame_arch (frame);
> -
>    if (!m_have_parsed_args)
>      {
>        if (this->can_evaluate_arguments ())
> -- 
> 2.20.1 (Apple Git-117)
  
Sergio Durigan Junior Sept. 4, 2019, 6 p.m. UTC | #2
On Wednesday, September 04 2019, I wrote:

> On Wednesday, August 21 2019, Alan Hayward wrote:
>
>> The probe function get_argument_count does not need a frame, only
>> the current gdbarch.  Switch the code to pass gdbarch instead.
>> No functional changes.
>
> The patch looks good at first glance, but I'd like to apply it before
> approving.  Unfortunately, it seems like your MUA has mangled the
> message (which is strange, because apparently you're using
> git-send-email):
>
>   <https://sourceware.org/cgi-bin/get-raw-msg?listname=gdb-patches&date=2019-08&msgid=20190821155816.45504-3-alan.hayward%40arm.com>
>
> Can you resend it, please?

Ah, I see that the whole patch series has already been pushed.  Sorry,
and please disregard my message.

Thanks,
  

Patch

diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
index 0677a55ee5..2c2a3b7d72 100644
--- a/gdb/break-catch-throw.c
+++ b/gdb/break-catch-throw.c
@@ -113,7 +113,7 @@  fetch_probe_arguments (struct value **arg0, struct value **arg1)
 	  && pc_probe.prob->get_name () != "rethrow"))
     error (_("not stopped at a C++ exception catchpoint"));
 
-  n_args = pc_probe.prob->get_argument_count (frame);
+  n_args = pc_probe.prob->get_argument_count (get_frame_arch (frame));
   if (n_args < 2)
     error (_("C++ exception catchpoint has too few arguments"));
 
diff --git a/gdb/dtrace-probe.c b/gdb/dtrace-probe.c
index 2d92edb11c..e9e71fd4c9 100644
--- a/gdb/dtrace-probe.c
+++ b/gdb/dtrace-probe.c
@@ -122,7 +122,7 @@  public:
   CORE_ADDR get_relocated_address (struct objfile *objfile) override;
 
   /* See probe.h.  */
-  unsigned get_argument_count (struct frame_info *frame) override;
+  unsigned get_argument_count (struct gdbarch *gdbarch) override;
 
   /* See probe.h.  */
   bool can_evaluate_arguments () const override;
@@ -693,7 +693,7 @@  dtrace_probe::get_relocated_address (struct objfile *objfile)
 /* Implementation of the get_argument_count method.  */
 
 unsigned
-dtrace_probe::get_argument_count (struct frame_info *frame)
+dtrace_probe::get_argument_count (struct gdbarch *gdbarch)
 {
   return m_args.size ();
 }
diff --git a/gdb/probe.c b/gdb/probe.c
index cdc6e021d2..8b108d6b02 100644
--- a/gdb/probe.c
+++ b/gdb/probe.c
@@ -695,7 +695,7 @@  probe_safe_evaluate_at_pc (struct frame_info *frame, unsigned n)
   if (!probe.prob)
     return NULL;
 
-  n_args = probe.prob->get_argument_count (frame);
+  n_args = probe.prob->get_argument_count (get_frame_arch (frame));
   if (n >= n_args)
     return NULL;
 
@@ -818,7 +818,7 @@  compute_probe_arg (struct gdbarch *arch, struct internalvar *ivar,
   if (pc_probe.prob == NULL)
     error (_("No probe at PC %s"), core_addr_to_string (pc));
 
-  n_args = pc_probe.prob->get_argument_count (frame);
+  n_args = pc_probe.prob->get_argument_count (arch);
   if (sel == -1)
     return value_from_longest (builtin_type (arch)->builtin_int, n_args);
 
@@ -840,7 +840,6 @@  compile_probe_arg (struct internalvar *ivar, struct agent_expr *expr,
   int sel = (int) (uintptr_t) data;
   struct bound_probe pc_probe;
   int n_args;
-  struct frame_info *frame = get_selected_frame (NULL);
 
   /* SEL == -1 means "_probe_argc".  */
   gdb_assert (sel >= -1);
@@ -849,7 +848,7 @@  compile_probe_arg (struct internalvar *ivar, struct agent_expr *expr,
   if (pc_probe.prob == NULL)
     error (_("No probe at PC %s"), core_addr_to_string (pc));
 
-  n_args = pc_probe.prob->get_argument_count (frame);
+  n_args = pc_probe.prob->get_argument_count (expr->gdbarch);
 
   if (sel == -1)
     {
diff --git a/gdb/probe.h b/gdb/probe.h
index 8abf69e354..7410c5aadf 100644
--- a/gdb/probe.h
+++ b/gdb/probe.h
@@ -131,7 +131,7 @@  public:
 
   /* Return the number of arguments of the probe.  This function can
      throw an exception.  */
-  virtual unsigned get_argument_count (struct frame_info *frame) = 0;
+  virtual unsigned get_argument_count (struct gdbarch *gdbarch) = 0;
 
   /* Return 1 if the probe interface can evaluate the arguments of
      probe, zero otherwise.  See the comments on
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index b21eacb68f..2a44dd6985 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -1756,7 +1756,7 @@  solib_event_probe_action (struct probe_and_action *pa)
        arg2: struct link_map *new (optional, for incremental updates)  */
   try
     {
-      probe_argc = pa->prob->get_argument_count (frame);
+      probe_argc = pa->prob->get_argument_count (get_frame_arch (frame));
     }
   catch (const gdb_exception_error &ex)
     {
diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c
index b6de873d2c..700b657967 100644
--- a/gdb/stap-probe.c
+++ b/gdb/stap-probe.c
@@ -136,7 +136,7 @@  public:
   CORE_ADDR get_relocated_address (struct objfile *objfile) override;
 
   /* See probe.h.  */
-  unsigned get_argument_count (struct frame_info *frame) override;
+  unsigned get_argument_count (struct gdbarch *gdbarch) override;
 
   /* See probe.h.  */
   bool can_evaluate_arguments () const override;
@@ -1301,10 +1301,8 @@  stap_probe::get_relocated_address (struct objfile *objfile)
    argument string.  */
 
 unsigned
-stap_probe::get_argument_count (struct frame_info *frame)
+stap_probe::get_argument_count (struct gdbarch *gdbarch)
 {
-  struct gdbarch *gdbarch = get_frame_arch (frame);
-
   if (!m_have_parsed_args)
     {
       if (this->can_evaluate_arguments ())