Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@ericsson.com>
To: <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@ericsson.com>
Subject: [PUSHED] Handle OP_STRING in dump_subexp_body_standard
Date: Tue, 15 Jul 2014 15:33:00 -0000	[thread overview]
Message-ID: <1405437917-1170-1-git-send-email-simon.marchi@ericsson.com> (raw)

Following this...
https://sourceware.org/ml/gdb-patches/2014-07/msg00383.html
...this patched was pushed.

For some reason, OP_STRING is not handled in dump_subexp_body_standard.
This makes the output of "set debug expression 1" very bad when a string
is involved. Example:

(gdb) set debug expression 1
(gdb) print "hello"
... (random garbage, possibly segfault)

This commit handles OP_STRING and skips the appropriate number of exp
elements. The line corresponding to the string now looks like:

	    0  OP_STRING             Language-specific string type: 0

gdb/ChangeLog:

2014-07-15  Simon Marchi  <simon.marchi@ericsson.com>

	* expprint.c (dump_subexp_body_standard): Handle OP_STRING.
---
 gdb/ChangeLog  |  4 ++++
 gdb/expprint.c | 19 ++++++++++++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index eca73a4..157dc49 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2014-07-15  Simon Marchi  <simon.marchi@ericsson.com>
+
+	* expprint.c (dump_subexp_body_standard): Handle OP_STRING.
+
 2014-07-14  Edjunior Barbosa Machado  <emachado@linux.vnet.ibm.com>
 
 	* ppc-linux-nat.c (ppc_linux_can_use_hw_breakpoint): Report no hardware
diff --git a/gdb/expprint.c b/gdb/expprint.c
index 97188ed..aa9e4d7 100644
--- a/gdb/expprint.c
+++ b/gdb/expprint.c
@@ -1011,12 +1011,29 @@ dump_subexp_body_standard (struct expression *exp,
 	elt = dump_subexp (exp, stream, elt);
       }
       break;
+    case OP_STRING:
+      {
+	LONGEST len = exp->elts[elt].longconst;
+	LONGEST type = exp->elts[elt + 1].longconst;
+
+	fprintf_filtered (stream, "Language-specific string type: %s",
+			  plongest (type));
+
+	/* Skip length.  */
+	elt += 1;
+
+	/* Skip string content. */
+	elt += BYTES_TO_EXP_ELEM (len);
+
+	/* Skip length and ending OP_STRING. */
+	elt += 2;
+      }
+      break;
     default:
     case OP_NULL:
     case MULTI_SUBSCRIPT:
     case OP_F77_UNDETERMINED_ARGLIST:
     case OP_COMPLEX:
-    case OP_STRING:
     case OP_BOOL:
     case OP_M2_STRING:
     case OP_THIS:
-- 
2.0.0


             reply	other threads:[~2014-07-15 15:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-15 15:33 Simon Marchi [this message]
2014-07-15 15:44 ` Joel Brobecker
2014-07-15 15:45   ` Simon Marchi
2014-07-15 16:07     ` Joel Brobecker

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=1405437917-1170-1-git-send-email-simon.marchi@ericsson.com \
    --to=simon.marchi@ericsson.com \
    --cc=gdb-patches@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