public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Yao Qi <yao@codesourcery.com>
To: Pedro Alves <palves@redhat.com>
Cc: <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Only print entry values for arguments.
Date: Thu, 08 Aug 2013 06:38:00 -0000	[thread overview]
Message-ID: <52033CB7.3070202@codesourcery.com> (raw)
In-Reply-To: <51FFB2A5.8040005@redhat.com>

On 08/05/2013 10:11 PM, Pedro Alves wrote:
>> >+	mi_gdb_test "-gdb-set print entry-values no" {\^done} ""
> Was there a reason to make the message argument the empty string?
> 

No.  I thought "set print entry-values no" is not important to show up
in the test summary gdb.sum, so I use empty string here.  Fix it like
this,

       mi_gdb_test "-gdb-set print entry-values no" {\^done} \
           "-gdb-set print entry-values no"

> I'd rather that bit was mentioned in the ChangeLog too:
> 
>> >2013-08-05  Yao Qi<yao@codesourcery.com>
>> >
>> >	* gdb.trace/mi-trace-unavailable.exp: Don't set
>> >	"print entry-values" to "no".
>> >	(test_trace_unavailable): Set various values to
>> >	"print entry-values" to test the output of
>> >	'-stack-list-locals' is not affected.
>   	(test_trace_unavailable): Set various values to
>   	"print entry-values" to test that the output of
>   	'-stack-list-locals' is not affected, and then set
> 	set "print entry-values" to "no".
> 

Fixed as you suggested.  Patch is committed to trunk as below.

> Otherwise it looks good to me.  I wonder whether we should put
> this in 7.6.1 ?

This problem exists on 7.6 branch too,

(gdb) interpreter-exec mi "-stack-list-locals 2"
^done,locals=[{name="b",type="int",value="2"}]
(gdb) set print entry-values only
(gdb) interpreter-exec mi "-stack-list-locals 2"
^done,locals=[{name="b@entry",type="int",value="<optimized out>"}]

We can apply this patch to 7.6 branch except the test case part,
because gdb.trace/mi-trace-unavailable.exp doesn't exist on 7.6
branch.  I plan to
 1) cvs -d :ext:qiyao@sourceware.org:/cvs/src co -r gdb_7_6-branch gdb
 2) apply this patch without changes to gdb.trace/mi-trace-unavailable.exp

Since it is not a bug fix, don't have to mention it in
http://sourceware.org/gdb/wiki/GDB_7.6_Release .  If my understanding
is right, I'll commit the patch to 7.6 branch.

-- 
Yao (齐尧)

gdb:

2013-08-08  Yao Qi  <yao@codesourcery.com>

	* frame.h (read_frame_local): Declare.
	* mi/mi-cmd-stack.c (list_args_or_locals): Call
	read_frame_local.
	* stack.c (read_frame_local): New.

gdb/testsuite:

2013-08-08  Yao Qi  <yao@codesourcery.com>

	* gdb.trace/mi-trace-unavailable.exp: Don't set
	"print entry-values" to "no".
	(test_trace_unavailable): Set various values to
	"print entry-values" to test the output of
	'-stack-list-locals' is not affected, , and then set
	"print entry-values" to "no".
---
 gdb/frame.h                                      |    2 ++
 gdb/mi/mi-cmd-stack.c                            |    5 ++++-
 gdb/stack.c                                      |   21 +++++++++++++++++++++
 gdb/testsuite/gdb.trace/mi-trace-unavailable.exp |   19 ++++++++++++++++---
 4 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/gdb/frame.h b/gdb/frame.h
index 31b9cb7..f02addf 100644
--- a/gdb/frame.h
+++ b/gdb/frame.h
@@ -714,6 +714,8 @@ struct frame_arg
 extern void read_frame_arg (struct symbol *sym, struct frame_info *frame,
 			    struct frame_arg *argp,
 			    struct frame_arg *entryargp);
+extern void read_frame_local (struct symbol *sym, struct frame_info *frame,
+			      struct frame_arg *argp);
 
 extern void args_info (char *, int);
 
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index 9294e46..e542fc1 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -602,7 +602,10 @@ list_args_or_locals (enum what_to_list what, enum print_values values,
 		      && TYPE_CODE (type) != TYPE_CODE_UNION)
 		    {
 		case PRINT_ALL_VALUES:
-		      read_frame_arg (sym2, fi, &arg, &entryarg);
+		  if (SYMBOL_IS_ARGUMENT (sym))
+		    read_frame_arg (sym2, fi, &arg, &entryarg);
+		  else
+		    read_frame_local (sym2, fi, &arg);
 		    }
 		  break;
 		}
diff --git a/gdb/stack.c b/gdb/stack.c
index d89ff89..7d97dc8 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -301,6 +301,27 @@ print_frame_arg (const struct frame_arg *arg)
   annotate_arg_end ();
 }
 
+/* Read in inferior function local SYM at FRAME into ARGP.  Caller is
+   responsible for xfree of ARGP->ERROR.  This function never throws an
+   exception.  */
+
+void
+read_frame_local (struct symbol *sym, struct frame_info *frame,
+		  struct frame_arg *argp)
+{
+  volatile struct gdb_exception except;
+  struct value *val = NULL;
+
+  TRY_CATCH (except, RETURN_MASK_ERROR)
+    {
+      val = read_var_value (sym, frame);
+    }
+
+  argp->error = (val == NULL) ? xstrdup (except.message) : NULL;
+  argp->sym = sym;
+  argp->val = val;
+}
+
 /* Read in inferior function parameter SYM at FRAME into ARGP.  Caller is
    responsible for xfree of ARGP->ERROR.  This function never throws an
    exception.  */
diff --git a/gdb/testsuite/gdb.trace/mi-trace-unavailable.exp b/gdb/testsuite/gdb.trace/mi-trace-unavailable.exp
index 42f6e32..d96ec8b 100644
--- a/gdb/testsuite/gdb.trace/mi-trace-unavailable.exp
+++ b/gdb/testsuite/gdb.trace/mi-trace-unavailable.exp
@@ -75,9 +75,6 @@ mi_gdb_test "-trace-save ${tracefile}.tf" ".*\\^done" \
 mi_gdb_test "-trace-save -ctf ${tracefile}.ctf" ".*\\^done" \
     "save ctf trace file"
 
-mi_gdb_test "-gdb-set print entry-values no" {\^done} \
-    "-gdb-set print entry-values no"
-
 proc test_trace_unavailable { data_source } {
     global decimal
 
@@ -89,6 +86,22 @@ proc test_trace_unavailable { data_source } {
 	    ".*\\^done,found=\"1\",tracepoint=\"${decimal}\",traceframe=\"0\",frame=\{.*" \
 	    "-trace-find frame-number 0"
 
+	# The "print entry-values" option shouldn't affect the output of
+	# '-stack-list-locals'.
+	foreach entry_values { no only preferred if-needed both compact default } {
+	    mi_gdb_test "-gdb-set print entry-values $entry_values" {\^done} ""
+
+	    with_test_prefix "$entry_values" {
+		# Test MI command '-stack-list-locals'.
+		mi_gdb_test "-stack-list-locals --simple-values" \
+		    ".*\\^done,locals=\\\[\{name=\"array\",type=\"unsigned char \\\[2\\\]\"\},\{name=\"i\",type=\"int\",value=\"<unavailable>\"\}\\\]" \
+		    "-stack-list-locals --simple-values"
+	    }
+	}
+
+	mi_gdb_test "-gdb-set print entry-values no" {\^done} \
+	    "-gdb-set print entry-values no"
+
 	# Test MI command '-stack-list-locals'.
 	mi_gdb_test "-stack-list-locals --simple-values" \
 	    ".*\\^done,locals=\\\[\{name=\"array\",type=\"unsigned char \\\[2\\\]\"\},\{name=\"i\",type=\"int\",value=\"<unavailable>\"\}\\\]" \
-- 
1.7.7.6

  reply	other threads:[~2013-08-08  6:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-05  0:45 Yao Qi
2013-08-05  2:10 ` Yao Qi
2013-08-05 14:12 ` Pedro Alves
2013-08-08  6:38   ` Yao Qi [this message]
2013-08-08 14:24     ` Pedro Alves
2013-08-14  9:46       ` Yao Qi
2013-08-14 11:17         ` Pedro Alves
2013-08-14 11:54           ` Yao Qi

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=52033CB7.3070202@codesourcery.com \
    --to=yao@codesourcery.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).