public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: "mjw at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: systemtap@sourceware.org
Subject: [Bug translator/14431] NULL/invalid char * pretty printed as "<unknown>" string
Date: Sat, 04 Aug 2012 22:58:00 -0000	[thread overview]
Message-ID: <bug-14431-6586-ys2ArKz3On@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-14431-6586@http.sourceware.org/bugzilla/>

http://sourceware.org/bugzilla/show_bug.cgi?id=14431

--- Comment #1 from Mark Wielaard <mjw at redhat dot com> 2012-08-04 22:57:54 UTC ---
What about we always also add the address of a char array?

diff --git a/tapsets.cxx b/tapsets.cxx
index 1068a42..edeb30c 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -2893,18 +2893,20 @@ dwarf_pretty_print::print_chars (Dwarf_Die* start_type,
target_symbol* e,
   const char *name = dwarf_diename (&type);
   if (name && (name == string("char") || name == string("unsigned char")))
     {
-      if (push_deref (pf, "\"%s\"", e))
+      if (push_deref (pf, "\"%s\"@%p", e))
         {
           // steal the last arg for a string access
           assert (!pf->args.empty());
+          expression* expr = pf->args.back();
           functioncall* fcall = new functioncall;
           fcall->tok = e->tok;
           fcall->function = userspace_p ? "user_string2" : "kernel_string2";
-          fcall->args.push_back (pf->args.back());
+          fcall->args.push_back (expr);
           expression *err_msg = new literal_string ("<unknown>");
           err_msg->tok = e->tok;
           fcall->args.push_back (err_msg);
           pf->args.back() = fcall;
+         pf->args.push_back (expr);
         }
       return true;
     }

For our contrived example above that would give:

{.foo=""@0xcb4010, .foo_size=42, .bar=""@0xcb4050, .bar_size=47}
{.foo="<unknown>"@0x0, .foo_size=42, .bar="<unknown>"@0x2a, .bar_size=0}

Does that look reasonable or silly?

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

  reply	other threads:[~2012-08-04 22:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-03 10:30 [Bug translator/14431] New: " mjw at redhat dot com
2012-08-04 22:58 ` mjw at redhat dot com [this message]
2012-08-05 20:29 ` [Bug translator/14431] " jistone at redhat dot com
2012-08-06  8:43 ` [Bug translator/14431] char * always being printed as, possibly INVALID/NULL "<unknown>", string without giving actual address mjw at redhat dot com
2012-08-06 15:32 ` mjw at redhat dot com
2012-08-06 17:24 ` jistone at redhat dot com
2012-08-06 18:59 ` mjw at redhat dot com
2015-10-21 18:50 ` fche at redhat dot com

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=bug-14431-6586-ys2ArKz3On@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=systemtap@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).