Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Pedro Alves <palves@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: [FYI/pushed] ARI: Add detection of printf_vma and sprintf_vma (was: "Re: [PATCH] gdb/tracepoint.c: Don't use printf_vma")
Date: Sat, 19 Nov 2016 18:43:00 -0000	[thread overview]
Message-ID: <20161119184322.GD4132@adacore.com> (raw)
In-Reply-To: <1a578b5a-608e-b75e-7a68-687bae3c1aa8@redhat.com>

[-- 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


  reply	other threads:[~2016-11-19 18:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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     ` Joel Brobecker [this message]
2016-11-17  0:46 ` Pedro Alves

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=20161119184322.GD4132@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    /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