public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb/tracepoint.c: Don't use printf_vma
@ 2016-11-15 23:10 Pedro Alves
  2016-11-16 14:34 ` Luis Machado
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Pedro Alves @ 2016-11-15 23:10 UTC (permalink / raw)
  To: gdb-patches

I noticed that bfd's printf_vma prints to stdout directly:

  bfd-in2.h:202:#define printf_vma(x) fprintf_vma(stdout,x)

This is a bad idea in gdb, where we should use
gdb_stdout/gdb_stderr/gdb_stdlog, etc., to support redirection.

Eliminate uses of sprintf_vma too while at it.

Tested on Fedora 23, w/ gdbserver.

gdb/ChangeLog:
yyyy-mm-dd  Pedro Alves  <palves@redhat.com>

	* tracepoint.c (collection_list::add_memrange): Add gdbarch
	parameter.  Use paddress instead of printf_vma.  Adjust recursive
	calls.
	(collection_list::stringify): Use paddress and phex_nz instead of
	sprintf_vma.  Adjust add_memrange call.
	* tracepoint.h (collection_list::add_memrange): Declare new method.
---
 gdb/tracepoint.c | 60 ++++++++++++++++++++++++++------------------------------
 gdb/tracepoint.h |  3 ++-
 2 files changed, 30 insertions(+), 33 deletions(-)

diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 0cb12c7..7435380 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -906,15 +906,12 @@ collection_list::add_register (unsigned int regno)
 /* Add a memrange to a collection list.  */
 
 void
-collection_list::add_memrange (int type, bfd_signed_vma base,
+collection_list::add_memrange (struct gdbarch *gdbarch,
+			       int type, bfd_signed_vma base,
 			       unsigned long len)
 {
   if (info_verbose)
-    {
-      printf_filtered ("(%d,", type);
-      printf_vma (base);
-      printf_filtered (",%ld)\n", len);
-    }
+    printf_filtered ("(%d,%s,%ld)\n", type, paddress (gdbarch, base), len);
 
   /* type: memrange_absolute == memory, other n == basereg */
   /* base: addr if memory, offset if reg relative.  */
@@ -955,19 +952,16 @@ collection_list::collect_symbol (struct symbol *sym,
       offset = SYMBOL_VALUE_ADDRESS (sym);
       if (info_verbose)
 	{
-	  char tmp[40];
-
-	  sprintf_vma (tmp, offset);
 	  printf_filtered ("LOC_STATIC %s: collect %ld bytes at %s.\n",
 			   SYMBOL_PRINT_NAME (sym), len,
-			   tmp /* address */);
+			   paddress (gdbarch, offset));
 	}
       /* A struct may be a C++ class with static fields, go to general
 	 expression handling.  */
       if (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT)
 	treat_as_expr = 1;
       else
-	add_memrange (memrange_absolute, offset, len);
+	add_memrange (gdbarch, memrange_absolute, offset, len);
       break;
     case LOC_REGISTER:
       reg = SYMBOL_REGISTER_OPS (sym)->register_number (sym, gdbarch);
@@ -991,36 +985,36 @@ collection_list::collect_symbol (struct symbol *sym,
       offset = frame_offset + SYMBOL_VALUE (sym);
       if (info_verbose)
 	{
-	  printf_filtered ("LOC_LOCAL %s: Collect %ld bytes at offset ",
-			   SYMBOL_PRINT_NAME (sym), len);
-	  printf_vma (offset);
-	  printf_filtered (" from frame ptr reg %d\n", reg);
+	  printf_filtered ("LOC_LOCAL %s: Collect %ld bytes at offset %s"
+			   " from frame ptr reg %d\n",
+			   SYMBOL_PRINT_NAME (sym), len,
+			   paddress (gdbarch, offset), reg);
 	}
-      add_memrange (reg, offset, len);
+      add_memrange (gdbarch, reg, offset, len);
       break;
     case LOC_REGPARM_ADDR:
       reg = SYMBOL_VALUE (sym);
       offset = 0;
       if (info_verbose)
 	{
-	  printf_filtered ("LOC_REGPARM_ADDR %s: Collect %ld bytes at offset ",
-			   SYMBOL_PRINT_NAME (sym), len);
-	  printf_vma (offset);
-	  printf_filtered (" from reg %d\n", reg);
+	  printf_filtered ("LOC_REGPARM_ADDR %s: Collect %ld bytes at offset %s"
+			   " from reg %d\n",
+			   SYMBOL_PRINT_NAME (sym), len,
+			   paddress (gdbarch, offset), reg);
 	}
-      add_memrange (reg, offset, len);
+      add_memrange (gdbarch, reg, offset, len);
       break;
     case LOC_LOCAL:
       reg = frame_regno;
       offset = frame_offset + SYMBOL_VALUE (sym);
       if (info_verbose)
 	{
-	  printf_filtered ("LOC_LOCAL %s: Collect %ld bytes at offset ",
-			   SYMBOL_PRINT_NAME (sym), len);
-	  printf_vma (offset);
-	  printf_filtered (" from frame ptr reg %d\n", reg);
+	  printf_filtered ("LOC_LOCAL %s: Collect %ld bytes at offset %s"
+			   " from frame ptr reg %d\n",
+			   SYMBOL_PRINT_NAME (sym), len,
+			   paddress (gdbarch, offset), reg);
 	}
-      add_memrange (reg, offset, len);
+      add_memrange (gdbarch, reg, offset, len);
       break;
 
     case LOC_UNRESOLVED:
@@ -1186,7 +1180,6 @@ char **
 collection_list::stringify ()
 {
   char temp_buf[2048];
-  char tmp2[40];
   int count;
   int ndx = 0;
   char *(*str_list)[];
@@ -1233,12 +1226,12 @@ collection_list::stringify ()
   for (i = 0, count = 0, end = temp_buf; i < m_memranges.size (); i++)
     {
       QUIT;			/* Allow user to bail out with ^C.  */
-      sprintf_vma (tmp2, m_memranges[i].start);
       if (info_verbose)
 	{
 	  printf_filtered ("(%d, %s, %ld)\n", 
 			   m_memranges[i].type,
-			   tmp2, 
+			   paddress (target_gdbarch (),
+				     m_memranges[i].start),
 			   (long) (m_memranges[i].end
 				   - m_memranges[i].start));
 	}
@@ -1259,9 +1252,11 @@ collection_list::stringify ()
            "FFFFFFFF" (or more, depending on sizeof (unsigned)).
            Special-case it.  */
         if (m_memranges[i].type == memrange_absolute)
-          sprintf (end, "M-1,%s,%lX", tmp2, (long) length);
+          sprintf (end, "M-1,%s,%lX", phex_nz (m_memranges[i].start, 0),
+		   (long) length);
         else
-          sprintf (end, "M%X,%s,%lX", m_memranges[i].type, tmp2, (long) length);
+          sprintf (end, "M%X,%s,%lX", m_memranges[i].type,
+		   phex_nz (m_memranges[i].start, 0), (long) length);
       }
 
       count += strlen (end);
@@ -1454,7 +1449,8 @@ encode_actions_1 (struct command_line *action,
 		      addr = value_address (tempval);
 		      /* Initialize the TYPE_LENGTH if it is a typedef.  */
 		      check_typedef (exp->elts[1].type);
-		      collect->add_memrange (memrange_absolute, addr,
+		      collect->add_memrange (target_gdbarch (),
+					     memrange_absolute, addr,
 					     TYPE_LENGTH (exp->elts[1].type));
 		      collect->append_exp (exp.get ());
 		      break;
diff --git a/gdb/tracepoint.h b/gdb/tracepoint.h
index 855bb1d..36eeee6 100644
--- a/gdb/tracepoint.h
+++ b/gdb/tracepoint.h
@@ -252,7 +252,8 @@ public:
   void add_aexpr (agent_expr_up aexpr);
 
   void add_register (unsigned int regno);
-  void add_memrange (int type, bfd_signed_vma base,
+  void add_memrange (struct gdbarch *gdbarch,
+		     int type, bfd_signed_vma base,
 		     unsigned long len);
   void collect_symbol (struct symbol *sym,
 		       struct gdbarch *gdbarch,
-- 
2.5.5

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] gdb/tracepoint.c: Don't use printf_vma
  2016-11-15 23:10 [PATCH] gdb/tracepoint.c: Don't use printf_vma Pedro Alves
@ 2016-11-16 14:34 ` Luis Machado
  2016-11-16 23:58 ` Joel Brobecker
  2016-11-17  0:46 ` [PATCH] gdb/tracepoint.c: Don't use printf_vma Pedro Alves
  2 siblings, 0 replies; 6+ messages in thread
From: Luis Machado @ 2016-11-16 14:34 UTC (permalink / raw)
  To: Pedro Alves, gdb-patches

On 11/15/2016 05:10 PM, Pedro Alves wrote:
> I noticed that bfd's printf_vma prints to stdout directly:
>
>   bfd-in2.h:202:#define printf_vma(x) fprintf_vma(stdout,x)
>
> This is a bad idea in gdb, where we should use
> gdb_stdout/gdb_stderr/gdb_stdlog, etc., to support redirection.
>
> Eliminate uses of sprintf_vma too while at it.
>
> Tested on Fedora 23, w/ gdbserver.
>
> gdb/ChangeLog:
> yyyy-mm-dd  Pedro Alves  <palves@redhat.com>
>
> 	* tracepoint.c (collection_list::add_memrange): Add gdbarch
> 	parameter.  Use paddress instead of printf_vma.  Adjust recursive
> 	calls.
> 	(collection_list::stringify): Use paddress and phex_nz instead of
> 	sprintf_vma.  Adjust add_memrange call.
> 	* tracepoint.h (collection_list::add_memrange): Declare new method.
> ---
>  gdb/tracepoint.c | 60 ++++++++++++++++++++++++++------------------------------
>  gdb/tracepoint.h |  3 ++-
>  2 files changed, 30 insertions(+), 33 deletions(-)
>
> diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
> index 0cb12c7..7435380 100644
> --- a/gdb/tracepoint.c
> +++ b/gdb/tracepoint.c
> @@ -906,15 +906,12 @@ collection_list::add_register (unsigned int regno)
>  /* Add a memrange to a collection list.  */
>
>  void
> -collection_list::add_memrange (int type, bfd_signed_vma base,
> +collection_list::add_memrange (struct gdbarch *gdbarch,
> +			       int type, bfd_signed_vma base,
>  			       unsigned long len)
>  {
>    if (info_verbose)
> -    {
> -      printf_filtered ("(%d,", type);
> -      printf_vma (base);
> -      printf_filtered (",%ld)\n", len);
> -    }
> +    printf_filtered ("(%d,%s,%ld)\n", type, paddress (gdbarch, base), len);
>
>    /* type: memrange_absolute == memory, other n == basereg */
>    /* base: addr if memory, offset if reg relative.  */
> @@ -955,19 +952,16 @@ collection_list::collect_symbol (struct symbol *sym,
>        offset = SYMBOL_VALUE_ADDRESS (sym);
>        if (info_verbose)
>  	{
> -	  char tmp[40];
> -
> -	  sprintf_vma (tmp, offset);
>  	  printf_filtered ("LOC_STATIC %s: collect %ld bytes at %s.\n",
>  			   SYMBOL_PRINT_NAME (sym), len,
> -			   tmp /* address */);
> +			   paddress (gdbarch, offset));
>  	}
>        /* A struct may be a C++ class with static fields, go to general
>  	 expression handling.  */
>        if (TYPE_CODE (SYMBOL_TYPE (sym)) == TYPE_CODE_STRUCT)
>  	treat_as_expr = 1;
>        else
> -	add_memrange (memrange_absolute, offset, len);
> +	add_memrange (gdbarch, memrange_absolute, offset, len);
>        break;
>      case LOC_REGISTER:
>        reg = SYMBOL_REGISTER_OPS (sym)->register_number (sym, gdbarch);
> @@ -991,36 +985,36 @@ collection_list::collect_symbol (struct symbol *sym,
>        offset = frame_offset + SYMBOL_VALUE (sym);
>        if (info_verbose)
>  	{
> -	  printf_filtered ("LOC_LOCAL %s: Collect %ld bytes at offset ",
> -			   SYMBOL_PRINT_NAME (sym), len);
> -	  printf_vma (offset);
> -	  printf_filtered (" from frame ptr reg %d\n", reg);
> +	  printf_filtered ("LOC_LOCAL %s: Collect %ld bytes at offset %s"
> +			   " from frame ptr reg %d\n",
> +			   SYMBOL_PRINT_NAME (sym), len,
> +			   paddress (gdbarch, offset), reg);
>  	}
> -      add_memrange (reg, offset, len);
> +      add_memrange (gdbarch, reg, offset, len);
>        break;
>      case LOC_REGPARM_ADDR:
>        reg = SYMBOL_VALUE (sym);
>        offset = 0;
>        if (info_verbose)
>  	{
> -	  printf_filtered ("LOC_REGPARM_ADDR %s: Collect %ld bytes at offset ",
> -			   SYMBOL_PRINT_NAME (sym), len);
> -	  printf_vma (offset);
> -	  printf_filtered (" from reg %d\n", reg);
> +	  printf_filtered ("LOC_REGPARM_ADDR %s: Collect %ld bytes at offset %s"
> +			   " from reg %d\n",
> +			   SYMBOL_PRINT_NAME (sym), len,
> +			   paddress (gdbarch, offset), reg);
>  	}
> -      add_memrange (reg, offset, len);
> +      add_memrange (gdbarch, reg, offset, len);
>        break;
>      case LOC_LOCAL:
>        reg = frame_regno;
>        offset = frame_offset + SYMBOL_VALUE (sym);
>        if (info_verbose)
>  	{
> -	  printf_filtered ("LOC_LOCAL %s: Collect %ld bytes at offset ",
> -			   SYMBOL_PRINT_NAME (sym), len);
> -	  printf_vma (offset);
> -	  printf_filtered (" from frame ptr reg %d\n", reg);
> +	  printf_filtered ("LOC_LOCAL %s: Collect %ld bytes at offset %s"
> +			   " from frame ptr reg %d\n",
> +			   SYMBOL_PRINT_NAME (sym), len,
> +			   paddress (gdbarch, offset), reg);
>  	}
> -      add_memrange (reg, offset, len);
> +      add_memrange (gdbarch, reg, offset, len);
>        break;
>
>      case LOC_UNRESOLVED:
> @@ -1186,7 +1180,6 @@ char **
>  collection_list::stringify ()
>  {
>    char temp_buf[2048];
> -  char tmp2[40];
>    int count;
>    int ndx = 0;
>    char *(*str_list)[];
> @@ -1233,12 +1226,12 @@ collection_list::stringify ()
>    for (i = 0, count = 0, end = temp_buf; i < m_memranges.size (); i++)
>      {
>        QUIT;			/* Allow user to bail out with ^C.  */
> -      sprintf_vma (tmp2, m_memranges[i].start);
>        if (info_verbose)
>  	{
>  	  printf_filtered ("(%d, %s, %ld)\n",
>  			   m_memranges[i].type,
> -			   tmp2,
> +			   paddress (target_gdbarch (),
> +				     m_memranges[i].start),
>  			   (long) (m_memranges[i].end
>  				   - m_memranges[i].start));
>  	}
> @@ -1259,9 +1252,11 @@ collection_list::stringify ()
>             "FFFFFFFF" (or more, depending on sizeof (unsigned)).
>             Special-case it.  */
>          if (m_memranges[i].type == memrange_absolute)
> -          sprintf (end, "M-1,%s,%lX", tmp2, (long) length);
> +          sprintf (end, "M-1,%s,%lX", phex_nz (m_memranges[i].start, 0),
> +		   (long) length);
>          else
> -          sprintf (end, "M%X,%s,%lX", m_memranges[i].type, tmp2, (long) length);
> +          sprintf (end, "M%X,%s,%lX", m_memranges[i].type,
> +		   phex_nz (m_memranges[i].start, 0), (long) length);
>        }
>
>        count += strlen (end);
> @@ -1454,7 +1449,8 @@ encode_actions_1 (struct command_line *action,
>  		      addr = value_address (tempval);
>  		      /* Initialize the TYPE_LENGTH if it is a typedef.  */
>  		      check_typedef (exp->elts[1].type);
> -		      collect->add_memrange (memrange_absolute, addr,
> +		      collect->add_memrange (target_gdbarch (),
> +					     memrange_absolute, addr,
>  					     TYPE_LENGTH (exp->elts[1].type));
>  		      collect->append_exp (exp.get ());
>  		      break;
> diff --git a/gdb/tracepoint.h b/gdb/tracepoint.h
> index 855bb1d..36eeee6 100644
> --- a/gdb/tracepoint.h
> +++ b/gdb/tracepoint.h
> @@ -252,7 +252,8 @@ public:
>    void add_aexpr (agent_expr_up aexpr);
>
>    void add_register (unsigned int regno);
> -  void add_memrange (int type, bfd_signed_vma base,
> +  void add_memrange (struct gdbarch *gdbarch,
> +		     int type, bfd_signed_vma base,
>  		     unsigned long len);
>    void collect_symbol (struct symbol *sym,
>  		       struct gdbarch *gdbarch,
>

Looks sane to me.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] gdb/tracepoint.c: Don't use printf_vma
  2016-11-15 23:10 [PATCH] gdb/tracepoint.c: Don't use printf_vma Pedro Alves
  2016-11-16 14:34 ` Luis Machado
@ 2016-11-16 23:58 ` Joel Brobecker
  2016-11-17  0:12   ` Pedro Alves
  2016-11-17  0:46 ` [PATCH] gdb/tracepoint.c: Don't use printf_vma Pedro Alves
  2 siblings, 1 reply; 6+ messages in thread
From: Joel Brobecker @ 2016-11-16 23:58 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

> I noticed that bfd's printf_vma prints to stdout directly:
> 
>   bfd-in2.h:202:#define printf_vma(x) fprintf_vma(stdout,x)
> 
> This is a bad idea in gdb, where we should use
> gdb_stdout/gdb_stderr/gdb_stdlog, etc., to support redirection.
> 
> Eliminate uses of sprintf_vma too while at it.
> 
> Tested on Fedora 23, w/ gdbserver.
> 
> gdb/ChangeLog:
> yyyy-mm-dd  Pedro Alves  <palves@redhat.com>
> 
> 	* tracepoint.c (collection_list::add_memrange): Add gdbarch
> 	parameter.  Use paddress instead of printf_vma.  Adjust recursive
> 	calls.
> 	(collection_list::stringify): Use paddress and phex_nz instead of
> 	sprintf_vma.  Adjust add_memrange call.
> 	* tracepoint.h (collection_list::add_memrange): Declare new method.

How about adding an ARI rule for those? I think it would help
avoid this function creeping back in.

It's not very difficult, and I might be able to find some time
this weekend to take care of it.

-- 
Joel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] gdb/tracepoint.c: Don't use printf_vma
  2016-11-16 23:58 ` Joel Brobecker
@ 2016-11-17  0:12   ` Pedro Alves
  2016-11-19 18:43     ` [FYI/pushed] ARI: Add detection of printf_vma and sprintf_vma (was: "Re: [PATCH] gdb/tracepoint.c: Don't use printf_vma") Joel Brobecker
  0 siblings, 1 reply; 6+ messages in thread
From: Pedro Alves @ 2016-11-17  0:12 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

On 11/16/2016 11:58 PM, Joel Brobecker wrote:
>> I noticed that bfd's printf_vma prints to stdout directly:
>>
>>   bfd-in2.h:202:#define printf_vma(x) fprintf_vma(stdout,x)
>>
>> This is a bad idea in gdb, where we should use
>> gdb_stdout/gdb_stderr/gdb_stdlog, etc., to support redirection.
>>
>> Eliminate uses of sprintf_vma too while at it.
>>
>> Tested on Fedora 23, w/ gdbserver.
>>
>> gdb/ChangeLog:
>> yyyy-mm-dd  Pedro Alves  <palves@redhat.com>
>>
>> 	* tracepoint.c (collection_list::add_memrange): Add gdbarch
>> 	parameter.  Use paddress instead of printf_vma.  Adjust recursive
>> 	calls.
>> 	(collection_list::stringify): Use paddress and phex_nz instead of
>> 	sprintf_vma.  Adjust add_memrange call.
>> 	* tracepoint.h (collection_list::add_memrange): Declare new method.
> 
> How about adding an ARI rule for those? I think it would help
> avoid this function creeping back in.

Indeed, sounds like a good idea.

> It's not very difficult, and I might be able to find some time
> this weekend to take care of it.

Thanks!

-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] gdb/tracepoint.c: Don't use printf_vma
  2016-11-15 23:10 [PATCH] gdb/tracepoint.c: Don't use printf_vma Pedro Alves
  2016-11-16 14:34 ` Luis Machado
  2016-11-16 23:58 ` Joel Brobecker
@ 2016-11-17  0:46 ` Pedro Alves
  2 siblings, 0 replies; 6+ messages in thread
From: Pedro Alves @ 2016-11-17  0:46 UTC (permalink / raw)
  To: gdb-patches

On 11/15/2016 11:10 PM, Pedro Alves wrote:
> I noticed that bfd's printf_vma prints to stdout directly:
> 
>   bfd-in2.h:202:#define printf_vma(x) fprintf_vma(stdout,x)
> 
> This is a bad idea in gdb, where we should use
> gdb_stdout/gdb_stderr/gdb_stdlog, etc., to support redirection.
> 
> Eliminate uses of sprintf_vma too while at it.
> 
> Tested on Fedora 23, w/ gdbserver.
> 
> gdb/ChangeLog:
> yyyy-mm-dd  Pedro Alves  <palves@redhat.com>
> 
> 	* tracepoint.c (collection_list::add_memrange): Add gdbarch
> 	parameter.  Use paddress instead of printf_vma.  Adjust recursive
> 	calls.
> 	(collection_list::stringify): Use paddress and phex_nz instead of
> 	sprintf_vma.  Adjust add_memrange call.
> 	* tracepoint.h (collection_list::add_memrange): Declare new method.

Now pushed.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [FYI/pushed] ARI: Add detection of printf_vma and sprintf_vma (was: "Re: [PATCH] gdb/tracepoint.c: Don't use printf_vma")
  2016-11-17  0:12   ` Pedro Alves
@ 2016-11-19 18:43     ` Joel Brobecker
  0 siblings, 0 replies; 6+ messages in thread
From: Joel Brobecker @ 2016-11-19 18:43 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 736 bytes --]

> >> gdb/ChangeLog:
> >> yyyy-mm-dd  Pedro Alves  <palves@redhat.com>
> >>
> >> 	* tracepoint.c (collection_list::add_memrange): Add gdbarch
> >> 	parameter.  Use paddress instead of printf_vma.  Adjust recursive
> >> 	calls.
> >> 	(collection_list::stringify): Use paddress and phex_nz instead of
> >> 	sprintf_vma.  Adjust add_memrange call.
> >> 	* tracepoint.h (collection_list::add_memrange): Declare new method.
> > 
> > How about adding an ARI rule for those? I think it would help
> > avoid this function creeping back in.
> 
> Indeed, sounds like a good idea.

Thanks! I just pushed the attached patch to master.

gdb/ChangeLog:

        * contrib/ari/gdb_ari.sh: Add detection of printf_vma and
        sprintf_vma.

-- 
Joel

[-- Attachment #2: 0001-ARI-Add-detection-of-printf_vma-and-sprintf_vma.patch --]
[-- Type: text/x-diff, Size: 1750 bytes --]

From cc188e5fd6d4f8d3061ed6c58c432a150f7966e9 Mon Sep 17 00:00:00 2001
From: Joel Brobecker <brobecker@adacore.com>
Date: Sat, 19 Nov 2016 10:40:17 -0800
Subject: [PATCH] ARI: Add detection of printf_vma and sprintf_vma

We shouldn't be using these, since their output goes straight to
stdout, which doesn't allow redirection. So this patch updates
the ARI to detect any such use.

gdb/ChangeLog:

        * contrib/ari/gdb_ari.sh: Add detection of printf_vma and
        sprintf_vma.
---
 gdb/ChangeLog              |  5 +++++
 gdb/contrib/ari/gdb_ari.sh | 16 ++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 07d21a6..3797e8b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2016-11-19  Joel Brobecker  <brobecker@adacore.com>
+
+	* contrib/ari/gdb_ari.sh: Add detection of printf_vma and
+	sprintf_vma.
+
 2016-11-18  Simon Marchi  <simon.marchi@polymtl.ca>
 
 	* Makefile.in (%.o: $(srcdir)/gdbtk/generic/%.c): Fix typo.
diff --git a/gdb/contrib/ari/gdb_ari.sh b/gdb/contrib/ari/gdb_ari.sh
index 7e639e3..2ecc0d6 100755
--- a/gdb/contrib/ari/gdb_ari.sh
+++ b/gdb/contrib/ari/gdb_ari.sh
@@ -1097,6 +1097,22 @@ Do not use vasprintf(), instead use xstrvprintf"
     fail("vasprintf")
 }
 
+BEGIN { doc["printf_vma"] = "\
+Do not use printf_vma, instead use paddress or phex_nz"
+    category["printf_vma"] = ari_code
+}
+/(^|[^_[:alnum:]])printf_vma[[:space:]]*\(/ {
+    fail("printf_vma")
+}
+
+BEGIN { doc["sprintf_vma"] = "\
+Do not use sprintf_vma, instead use paddress or phex_nz"
+    category["sprintf_vma"] = ari_code
+}
+/(^|[^_[:alnum:]])sprintf_vma[[:space:]]*\(/ {
+    fail("sprintf_vma")
+}
+
 # More generic memory operations
 
 BEGIN { doc["bzero"] = "\
-- 
2.5.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-11-19 18:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-15 23:10 [PATCH] gdb/tracepoint.c: Don't use printf_vma Pedro Alves
2016-11-16 14:34 ` Luis Machado
2016-11-16 23:58 ` Joel Brobecker
2016-11-17  0:12   ` Pedro Alves
2016-11-19 18:43     ` [FYI/pushed] ARI: Add detection of printf_vma and sprintf_vma (was: "Re: [PATCH] gdb/tracepoint.c: Don't use printf_vma") Joel Brobecker
2016-11-17  0:46 ` [PATCH] gdb/tracepoint.c: Don't use printf_vma Pedro Alves

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).